summaryrefslogtreecommitdiff
path: root/nvim/lua
diff options
context:
space:
mode:
authorzachir <zachir@librem.one>2025-04-17 23:05:26 -0500
committerzachir <zachir@librem.one>2025-04-17 23:05:26 -0500
commit511945a793625d87340f04800cd1c5bdafc3b379 (patch)
treec316999e489212612ca2147944b10f2f9a33dda8 /nvim/lua
parent2702c566c5a168965f2238a1b1d738b399543137 (diff)
parentc7373b980589d7a5ea795b0dfd750a01a83718bb (diff)
Merge branch 'master' into clacla
Diffstat (limited to 'nvim/lua')
-rw-r--r--nvim/lua/colorscheme.lua8
-rw-r--r--nvim/lua/keymaps.lua97
-rw-r--r--nvim/lua/options.lua32
-rw-r--r--nvim/lua/plugins.lua106
-rw-r--r--nvim/lua/term.lua51
5 files changed, 294 insertions, 0 deletions
diff --git a/nvim/lua/colorscheme.lua b/nvim/lua/colorscheme.lua
new file mode 100644
index 0000000..66516fa
--- /dev/null
+++ b/nvim/lua/colorscheme.lua
@@ -0,0 +1,8 @@
+-- define your colorscheme here
+local colorscheme = 'badwolf'
+
+local is_ok, _ = pcall(vim.cmd, "colorscheme " .. colorscheme)
+if not is_ok then
+ vim.notify('colorscheme ' .. colorscheme .. ' not found!')
+ return
+end
diff --git a/nvim/lua/keymaps.lua b/nvim/lua/keymaps.lua
new file mode 100644
index 0000000..26037c6
--- /dev/null
+++ b/nvim/lua/keymaps.lua
@@ -0,0 +1,97 @@
+-- define common options
+local opts = {
+ noremap = true, -- non-recursive
+ silent = true, -- do not show message
+}
+
+-- set leader key
+vim.g.mapleader = "'"
+
+-----------------
+-- Normal mode --
+-----------------
+
+-- Hint: set `:h vim.map.set()`
+-- Better window navigation
+vim.keymap.set('n', '<C-h>', '<C-w>h', opts)
+vim.keymap.set('n', '<C-j>', '<C-w>j', opts)
+vim.keymap.set('n', '<C-k>', '<C-w>k', opts)
+vim.keymap.set('n', '<C-l>', '<C-w>l', opts)
+
+-- Resize with arrows
+vim.keymap.set('n', '<C-Up>', ':resize -2<CR>', opts)
+vim.keymap.set('n', '<C-Down>', ':resize +2<CR>', opts)
+vim.keymap.set('n', '<C-Left>', ':vertical resize -2<CR>', opts)
+vim.keymap.set('n', '<C-Right>', ':vertical resize +2<CR>', opts)
+vim.keymap.set('n', '<leader>wh :vertical resize', '-1<CR>')
+vim.keymap.set('n', '<leader>wj :resize', '-1<CR>')
+vim.keymap.set('n', '<leader>wk :resize', '+1<CR>')
+vim.keymap.set('n', '<leader>wl :vertical resize', '+1<CR>')
+
+-- NerdTREE
+vim.keymap.set('n', '<leader>tt', ':NERDTreeToggle<CR>')
+
+-- files
+-- these may go away soon
+vim.keymap.set('n', '<leader>xx', ':q<CR>')
+vim.keymap.set('n', '<leader>x!', ':q!<CR>')
+
+-- Close with leader
+vim.keymap.set('n', '<leader>ww', ':w<CR>', opts)
+vim.keymap.set('n', '<leader>qq', ':q<CR>', opts)
+vim.keymap.set('n', '<leader>wq', ':wq<CR>', opts)
+vim.keymap.set('n', '<leader>q!', ':q!<CR>', opts)
+vim.keymap.set('n', '<leader>wq', ':wq<CR>')
+vim.keymap.set('n', '<leader>ee :e', '')
+
+-- Tabs with leader
+vim.keymap.set('n', '<leader>th', ':tabprevious<CR>', opts)
+vim.keymap.set('n', '<leader>tl', ':tabnext<CR>', opts)
+vim.keymap.set('n', '<leader>tk', ':tabnew<CR>', opts)
+vim.keymap.set('n', '<leader>tj', ':tabclose<CR>', opts)
+
+-- Write with sudo
+vim.keymap.set('n', 'ZW', ':w !pkexec tee % >/dev/null', opts)
+
+-- clear search highlights
+vim.keymap.set('n', '<leader>/', ':noh<CR>')
+
+-- toggles
+vim.keymap.set('n', '<leader>tn :set', 'number!<CR>')
+vim.keymap.set('n', '<leader>tr :set', 'relativenumber!<CR>')
+
+-- write as root
+vim.keymap.set('n', 'ZW', ':w !pkexec tee % >/dev/null')
+
+-- config
+vim.keymap.set('n', '<leader>en', ':e ~/.config/nvim/init.lua<CR>')
+vim.keymap.set('n', '<leader>ec', ':source %<CR>')
+vim.keymap.set('n', '<leader>er', ':source ~/.config/nvim/init.lua<CR>')
+
+-- Goyo
+vim.keymap.set('n', '<leader>G', ':Goyo<CR>')
+
+-- fugitive
+vim.keymap.set('n', '<leader>gp :G', 'pull<CR>')
+vim.keymap.set('n', '<leader>gd :G diff', '%<CR>')
+
+-----------------
+-- Visual mode --
+-----------------
+
+-- Hint: start visual mode with the same area as the previous area and the same mode
+--vim.keymap.set('v', '<', '<gv', opts)
+--vim.keymap.set('v', '>', '>gv', opts)
+
+-- windows
+vim.keymap.set('v', '<C-h>', '<C-w>h')
+vim.keymap.set('v', '<C-j>', '<C-w>j')
+vim.keymap.set('v', '<C-k>', '<C-w>k')
+vim.keymap.set('v', '<C-l>', '<C-w>l')
+
+--------------
+-- TERMINAL --
+--------------
+
+-- escape for term windows
+vim.keymap.set('t', '<Esc>', '<C-\\><C-n>')
diff --git a/nvim/lua/options.lua b/nvim/lua/options.lua
new file mode 100644
index 0000000..1d4826e
--- /dev/null
+++ b/nvim/lua/options.lua
@@ -0,0 +1,32 @@
+-- Hint: use `:h <option>` to figure out the meaning if needed
+vim.opt.clipboard = 'unnamedplus' -- use system clipboard
+vim.opt.completeopt = {'menu', 'menuone', 'noselect'}
+vim.opt.mouse = 'a' -- allow the mouse to be used in nvim
+
+-- Tab
+vim.opt.tabstop = 2 -- number of visual spaces per TAB
+vim.opt.softtabstop = 2 -- number of spaces in tab when editing
+vim.opt.shiftwidth = 2 -- insert 2 spaces on a tab
+vim.opt.expandtab = true -- tabs are spaces
+
+-- UI config
+vim.opt.number = true -- show absolute number
+vim.opt.relativenumber = true -- show relative numbers
+vim.opt.cursorline = true -- highlight cursor line underneath cursor horizontally
+vim.opt.splitbelow = true -- open new vertical splits bottom
+vim.opt.splitright = true -- open new horizontal splits right
+-- vim.opt.termguicolors = true -- enable 24-bit RGB color in the TUI
+vim.opt.showmode = false -- show the "-- INSERT --" and other hints
+
+-- Searching
+vim.opt.incsearch = true -- search as characters are entered
+vim.opt.hlsearch = false -- do not highlight matches
+vim.opt.ignorecase = true -- ignore case in searches by default
+vim.opt.smartcase = true -- but make it case sensitive if an uppercase is entered
+
+-- Etc
+vim.opt.ruler = true -- Show row and column ruler info
+vim.opt.undolevels = 1000 -- Number of undo levels
+vim.opt.backspace = { "indent", "eol", "start" } -- Backspace behavior
+vim.opt.foldmethod = "marker"
+vim.opt.conceallevel = 2
diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua
new file mode 100644
index 0000000..0801939
--- /dev/null
+++ b/nvim/lua/plugins.lua
@@ -0,0 +1,106 @@
+local lazypath = vim.fn.stdpath("data") .. "lazy/lazy.nvim"
+if not (vim.uv or vim.loop).fs_stat(lazypath) then
+ vim.fn.system({
+ "git",
+ "clone",
+ "--filter=blob:none",
+ "https://github.com/folke/lazy.nvim.git",
+ "--branch=stable", -- latest stable rtelease
+ lazypath,
+ })
+end
+vim.opt.rtp:prepend(lazypath)
+
+require("lazy").setup({
+ "tanvirtin/monokai.nvim",
+ 'preservim/nerdtree',
+ 'ziglang/zig.vim',
+ "lervag/vimtex",
+ 'tomasiser/vim-code-dark',
+ 'flazz/vim-colorschemes',
+ 'tomasiser/vim-code-dark',
+ 'flazz/vim-colorschemes',
+ 'ZachIndigo/vim-preglow',
+ 'axvr/org.vim',
+ 'ziglang/zig.vim',
+ 'jdonaldson/vaxe',
+ 'xuhdev/vim-latex-live-preview',
+ 'waycrate/swhkd-vim',
+ 'HiPhish/guile.vim',
+ 'preservim/nerdtree',
+ 'Xuyuanp/nerdtree-git-plugin',
+ 'PhilRunninger/nerdtree-visual-selection',
+ 'tpope/vim-fugitive',
+ 'junegunn/goyo.vim',
+ 'junegunn/limelight.vim',
+ 'vim-airline/vim-airline',
+ 'nathanaelkane/vim-indent-guides',
+ 'mhinz/vim-signify',
+ 'tpope/vim-endwise',
+ 'tpope/vim-surround',
+ 'mattn/emmet-vim',
+ 'godlygeek/tabular',
+ 'plasticboy/vim-markdown',
+ 'ryanoasis/vim-devicons',
+ {'akinsho/toggleterm.nvim', version = "*", config = true},
+})
+
+--------------------
+-- Plugin Options --
+--------------------
+
+-- emmet
+vim.g.user_emmet_leader_key='<C-a>'
+
+-- zig config
+vim.g.zig_fmt_autosave = 1
+
+-- latex live preview
+vim.g.livepreview_previewer = 'zathura'
+vim.g.livepreview_use_biber = 1
+vim.g.livepreview_cursorhold_recompile = 0
+
+-- vim-markdown
+vim.g.vim_markdown_folding_disabled = 1
+vim.g.vim_markdown_folding_level = 3
+vim.g.vim_markdown_toc_autofit = 1
+vim.g.vim_markdown_emphasis_multiline = 0
+vim.g.tex_conceal = ""
+vim.g.vim_markdown_math = 1
+vim.g.vim_markdown_conceal_code_blocks = 1
+vim.g.vim_markdown_fenced_languages = { 'c++=cpp', 'viml=vim', 'bash=sh', 'ini=dosini' }
+vim.g.vim_markdown_follow_anchor = 1
+vim.g.vim_markdown_math = 1
+vim.g.vim_markdown_frontmatter = 1
+vim.g.vim_markdown_toml_frontmatter = 1
+vim.g.vim_markdown_strikethrough = 1
+vim.g.vim_markdown_no_extensions_in_markdown = 1
+vim.g.vim_markdown_autowrite = 1
+vim.g.vim_markdown_auto_insert_bullets = 0
+vim.g.vim_markdown_new_list_item_indent = 0
+vim.g.vim_markdown_edit_url_in = 'tab'
+
+-- NERDTree config
+vim.g.NERDTreeGitStatusUseNerdFonts = 1 -- use nerd fonts
+vim.g.NERDTreeGitStatusShowClean = 1 -- default: 0
+vim.g.NERDTreeDirArrowExpandable = '>'
+vim.g.NERDTreeDirArrowCollapsible = '<'
+vim.g.NERDTreeMapToggleHidden = 'z'
+
+-- Goyo config
+vim.g.goyo_width = '90%'
+vim.g.goyo_height = '100%'
+
+-- limelight config
+vim.g.limelight_conceal_ctermfg = 'gray'
+vim.g.limelight_conceal_guifg = 'gray'
+
+-- devicon config
+vim.g.airline_powerline_fonts = 1
+vim.g.webdevicons_enable_nerdtree = 1
+
+-- vim-indent-guides config
+vim.g.indent_guides_enable_on_vim_startup = 0
+
+-- vim-signify config
+vim.opt.updatetime=100
diff --git a/nvim/lua/term.lua b/nvim/lua/term.lua
new file mode 100644
index 0000000..9f3062d
--- /dev/null
+++ b/nvim/lua/term.lua
@@ -0,0 +1,51 @@
+require("toggleterm").setup{
+ -- size can be a number or function which is passed the current terminal
+ size = function(term)
+ if term.direction == "horizontal" then
+ return 15
+ elseif term.direction == "vertical" then
+ return vim.o.columns * 0.4
+ end
+ end,
+ open_mapping = [[<c-\>]], -- or { [[<c-\>]], [[<c-¥>]] } if you also use a Japanese keyboard.
+ hide_numbers = true, -- hide the number column in toggleterm buffers
+ shade_filetypes = {},
+ autochdir = false, -- when neovim changes it current directory the terminal will change it's own when next it's opened
+ shade_terminals = true, -- NOTE: this option takes priority over highlights specified so if you specify Normal highlights you should set this to false
+ shading_factor = '-30', -- the percentage by which to lighten dark terminal background, default: -30
+ shading_ratio = '-3', -- the ratio of shading factor for light/dark terminal background, default: -3
+ start_in_insert = true,
+ insert_mappings = true, -- whether or not the open mapping applies in insert mode
+ terminal_mappings = true, -- whether or not the open mapping applies in the opened terminals
+ persist_size = true,
+ persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered
+ direction = 'horizontal',
+ close_on_exit = true, -- close the terminal window when the process exits
+ clear_env = false, -- use only environmental variables from `env`, passed to jobstart()
+ -- Change the default shell. Can be a string or a function returning a string
+ shell = vim.o.shell,
+ auto_scroll = true, -- automatically scroll to the bottom on terminal output
+ -- This field is only relevant if direction is set to 'float'
+ float_opts = {
+ -- The border key is *almost* the same as 'nvim_open_win'
+ -- see :h nvim_open_win for details on borders however
+ -- the 'curved' border is a custom border type
+ -- not natively supported but implemented in this plugin.
+ border = 'single',
+ -- like `size`, width, height, row, and col can be a number or function which is passed the current terminal
+ winblend = 3,
+ title_pos = 'left'
+ },
+ winbar = {
+ enabled = false,
+ name_formatter = function(term) -- term: Terminal
+ return term.name
+ end
+ },
+ responsiveness = {
+ -- breakpoint in terms of `vim.o.columns` at which terminals will start to stack on top of each other
+ -- instead of next to each other
+ -- default = 0 which means the feature is turned off
+ horizontal_breakpoint = 135,
+ }
+}