chore: refactored and cleaned up neovim config
82698f42
8 file(s) · +140 −142
| 1 | - | -- Suppress vim.tbl_islist deprecation warning |
|
| 2 | - | -- local original_deprecate = vim.deprecate |
|
| 3 | - | -- vim.deprecate = function(name, alternative, version, plugin, backtrace) |
|
| 4 | - | -- if name == "vim.tbl_islist" then |
|
| 5 | - | -- return |
|
| 6 | - | -- end |
|
| 7 | - | -- return original_deprecate(name, alternative, version, plugin, backtrace) |
|
| 8 | - | -- end |
|
| 9 | - | ||
| 10 | 1 | require("config.options") |
|
| 11 | 2 | require("core.lazy") |
|
| 12 | 3 | require("core.lsp") |
| 1 | 1 | { |
|
| 2 | - | "ai.vim": { "branch": "main", "commit": "8a0431fa69b65c1d5596e62dd9fd0993ce847894" }, |
|
| 3 | 2 | "darkmatter-nvim": { "branch": "main", "commit": "5663ddc9d8580c0c43b996e01bfe1a335789e9c9" }, |
|
| 3 | + | "friendly-snippets": { "branch": "main", "commit": "6cd7280adead7f586db6fccbd15d2cac7e2188b9" }, |
|
| 4 | 4 | "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, |
|
| 5 | 5 | "mini.nvim": { "branch": "main", "commit": "a995fe9cd4193fb492b5df69175a351a74b3d36b" }, |
|
| 6 | 6 | "vim-tmux-navigator": { "branch": "master", "commit": "e41c431a0c7b7388ae7ba341f01a0d217eb3a432" } |
| 1 | 1 | return { |
|
| 2 | - | cmd = { |
|
| 3 | - | "lua-language-server", |
|
| 4 | - | }, |
|
| 5 | - | filetypes = { |
|
| 6 | - | "lua", |
|
| 7 | - | }, |
|
| 8 | - | root_markers = { |
|
| 9 | - | ".git", |
|
| 10 | - | ".luacheckrc", |
|
| 11 | - | ".luarc.json", |
|
| 12 | - | ".luarc.jsonc", |
|
| 13 | - | ".stylua.toml", |
|
| 14 | - | "selene.toml", |
|
| 15 | - | "selene.yml", |
|
| 16 | - | "stylua.toml", |
|
| 17 | - | }, |
|
| 18 | - | -- settings = { |
|
| 19 | - | -- Lua = { |
|
| 20 | - | -- diagnostics = { |
|
| 21 | - | -- -- disable = { "missing-parameters", "missing-fields" }, |
|
| 22 | - | -- }, |
|
| 23 | - | -- }, |
|
| 24 | - | -- }, |
|
| 2 | + | cmd = { |
|
| 3 | + | "lua-language-server", |
|
| 4 | + | }, |
|
| 5 | + | filetypes = { |
|
| 6 | + | "lua", |
|
| 7 | + | }, |
|
| 8 | + | root_markers = { |
|
| 9 | + | ".git", |
|
| 10 | + | ".luacheckrc", |
|
| 11 | + | ".luarc.json", |
|
| 12 | + | ".luarc.jsonc", |
|
| 13 | + | ".stylua.toml", |
|
| 14 | + | "selene.toml", |
|
| 15 | + | "selene.yml", |
|
| 16 | + | "stylua.toml", |
|
| 17 | + | }, |
|
| 18 | + | settings = { |
|
| 19 | + | Lua = { |
|
| 20 | + | diagnostics = { |
|
| 21 | + | globals = { "vim", "MiniPick", "MiniSnippets" } |
|
| 22 | + | }, |
|
| 23 | + | }, |
|
| 24 | + | }, |
|
| 25 | 25 | ||
| 26 | - | single_file_support = true, |
|
| 27 | - | log_level = vim.lsp.protocol.MessageType.Warning, |
|
| 26 | + | single_file_support = true, |
|
| 27 | + | log_level = vim.lsp.protocol.MessageType.Warning, |
|
| 28 | 28 | } |
| 1 | 1 | local opts = { noremap = true, silent = true } |
|
| 2 | 2 | local map = vim.api.nvim_set_keymap |
|
| 3 | 3 | ||
| 4 | - | -- format |
|
| 5 | - | -- Fast saving |
|
| 4 | + | -- Saving |
|
| 6 | 5 | map("n", "++", "<cmd>write!<CR>", opts) |
|
| 7 | 6 | ||
| 8 | - | -- Some useful quickfix shortcuts for quickfix |
|
| 9 | - | map("n", "<C-n>", "<cmd>cnext<CR>zz", opts) |
|
| 10 | - | map("n", "<C-m>", "<cmd>cprev<CR>zz", opts) |
|
| 11 | - | map("n", "<leader>a", "<cmd>cclose<CR>", opts) |
|
| 12 | - | ||
| 13 | - | -- Exit on jj and jk |
|
| 7 | + | -- Navigation |
|
| 14 | 8 | map("n", "j", "gj", opts) |
|
| 15 | 9 | map("n", "k", "gk", opts) |
|
| 16 | - | ||
| 17 | - | -- Exit on jj and jk |
|
| 18 | - | map("i", "jj", "<ESC>", opts) |
|
| 19 | - | map("i", "jk", "<ESC>", opts) |
|
| 20 | - | ||
| 21 | - | -- Remove search highlight |
|
| 22 | - | map("n", "<leader>h", "<cmd>nohlsearch<CR>", opts) |
|
| 23 | - | ||
| 24 | - | -- Grab text between curly braces |
|
| 25 | - | map("n", "YY", "va{Vy", opts) |
|
| 26 | - | ||
| 27 | - | -- goodies |
|
| 28 | 10 | map("n", "n", "nzzzv", opts) |
|
| 29 | 11 | map("n", "N", "Nzzzv", opts) |
|
| 30 | - | map("n", "J", "mzJ`z", opts) |
|
| 31 | 12 | map("n", "<C-d>", "<C-d>zz", opts) |
|
| 32 | 13 | map("n", "<C-u>", "<C-u>zz", opts) |
|
| 33 | 14 | ||
| 34 | - | -- Navigate buffers |
|
| 15 | + | -- Buffers |
|
| 35 | 16 | map("n", "<S-l>", ":bnext<CR>", opts) |
|
| 36 | 17 | map("n", "<S-h>", ":bprevious<CR>", opts) |
|
| 18 | + | map("n", "<leader>o", "<cmd>Pick buffers<CR>", opts) |
|
| 19 | + | map("n", "<leader>c", ":bd<cr>", opts) |
|
| 20 | + | ||
| 21 | + | -- Quickfix |
|
| 22 | + | map("n", "<C-n>", "<cmd>cnext<CR>zz", opts) |
|
| 23 | + | map("n", "<C-m>", "<cmd>cprev<CR>zz", opts) |
|
| 24 | + | map("n", "<leader>a", "<cmd>cclose<CR>", opts) |
|
| 37 | 25 | ||
| 38 | - | -- If I visually select words and paste from clipboard, don't replace my |
|
| 39 | - | -- clipboard with the selected word, instead keep my old word in the |
|
| 40 | - | -- clipboard |
|
| 41 | - | map("x", "p", '"_dP', opts) |
|
| 26 | + | -- Search |
|
| 27 | + | map("n", "<leader>h", "<cmd>nohlsearch<CR>", opts) |
|
| 28 | + | map("n", "<leader>f", "<cmd>Pick files<CR>", opts) |
|
| 29 | + | map("n", "<leader>/", "<cmd>Pick grep_live<CR>", opts) |
|
| 30 | + | map("n", "<leader>hh", "<cmd>Pick help<CR>", opts) |
|
| 42 | 31 | ||
| 43 | - | -- Better split switching |
|
| 44 | - | -- map("n", "<C-h>", "<C-w>h", opts) |
|
| 45 | - | -- map("n", "<C-j>", "<C-w>j", opts) |
|
| 46 | - | -- map("n", "<C-k>", "<C-w>k", opts) |
|
| 47 | - | -- map("n", "<C-l>", "<C-w>l", opts) |
|
| 32 | + | -- Diagnostics |
|
| 33 | + | map("n", "<leader>d", "<cmd>Pick diagnostic<CR>", opts) |
|
| 34 | + | map("n", "<leader>dd", "<cmd>lua vim.diagnostic.open_float({ border = 'rounded' })<CR>", opts) |
|
| 48 | 35 | ||
| 49 | - | -- Visual -- |
|
| 50 | - | -- Stay in indent mode |
|
| 51 | - | map("v", "<", "<gv", opts) |
|
| 52 | - | map("v", ">", ">gv", opts) |
|
| 36 | + | -- Git |
|
| 37 | + | map("n", "<leader>gg", "<cmd>lua MiniDiff.toggle_overlay()<CR>", opts) |
|
| 53 | 38 | ||
| 54 | - | -- Visually select lines, and move them up/down |
|
| 55 | - | map("v", "J", ":m '>+1<CR>gv=gv", opts) |
|
| 56 | - | map("v", "K", ":m '<-2<CR>gv=gv", opts) |
|
| 39 | + | -- File explorer |
|
| 40 | + | map("n", "<leader>e", "<cmd>lua MiniFiles.open()<CR>", opts) |
|
| 57 | 41 | ||
| 58 | - | map("n", "<leader>c", ":bd<cr>", opts) |
|
| 42 | + | -- Spelling |
|
| 43 | + | vim.keymap.set("n", "<leader>s", function() |
|
| 44 | + | local word = vim.fn.expand("<cword>") |
|
| 45 | + | local suggestions = vim.fn.spellsuggest(word, 25) |
|
| 46 | + | MiniPick.start({ |
|
| 47 | + | source = { |
|
| 48 | + | items = suggestions, |
|
| 49 | + | name = "Spelling: " .. word, |
|
| 50 | + | choose = function(item) |
|
| 51 | + | vim.schedule(function() |
|
| 52 | + | vim.cmd("normal! ciw" .. item) |
|
| 53 | + | vim.cmd("stopinsert") |
|
| 54 | + | end) |
|
| 55 | + | end, |
|
| 56 | + | }, |
|
| 57 | + | }) |
|
| 58 | + | end, { desc = "Spelling suggestions" }) |
|
| 59 | 59 | ||
| 60 | - | map("n", "<leader>dd", "<cmd>lua vim.diagnostic.open_float({ border = 'rounded' })<CR>", opts) |
|
| 61 | - | map("n", "<leader>gg", "<cmd>lua MiniDiff.toggle_overlay()<CR>", opts) |
|
| 60 | + | -- Editing |
|
| 61 | + | map("n", "J", "mzJ`z", opts) |
|
| 62 | + | map("n", "YY", "va{Vy", opts) |
|
| 63 | + | map("x", "p", '"_dP', opts) |
|
| 62 | 64 | ||
| 65 | + | -- Insert mode |
|
| 66 | + | map("i", "jj", "<ESC>", opts) |
|
| 67 | + | map("i", "jk", "<ESC>", opts) |
|
| 63 | 68 | map("i", "<C-j>", 'pumvisible() ? "\\<C-n>" : "\\<C-j>"', { expr = true, noremap = true, silent = true }) |
|
| 64 | 69 | map("i", "<C-k>", 'pumvisible() ? "\\<C-p>" : "\\<C-k>"', { expr = true, noremap = true, silent = true }) |
|
| 65 | 70 | ||
| 66 | - | map("n", "<leader>e", "<cmd>lua MiniFiles.open()<CR>", opts) |
|
| 67 | - | ||
| 68 | - | map("n", "<leader>o", "<cmd>Pick buffers<CR>", opts) |
|
| 69 | - | map("n", "<leader>f", "<cmd>Pick files<CR>", opts) |
|
| 70 | - | map("n", "<leader>/", "<cmd>Pick grep_live<CR>", opts) |
|
| 71 | - | map("n", "<leader>hh", "<cmd>Pick help<CR>", opts) |
|
| 72 | - | map("n", "<leader>d", "<cmd>Pick diagnostic<CR>", opts) |
|
| 71 | + | -- Visual mode |
|
| 72 | + | map("v", "<", "<gv", opts) |
|
| 73 | + | map("v", ">", ">gv", opts) |
|
| 74 | + | map("v", "J", ":m '>+1<CR>gv=gv", opts) |
|
| 75 | + | map("v", "K", ":m '<-2<CR>gv=gv", opts) |
| 1 | 1 | vim.g.mapleader = " " |
|
| 2 | 2 | vim.g.maplocalleader = "\\" |
|
| 3 | - | ||
| 4 | 3 | vim.g.autoformat = true |
|
| 5 | - | ||
| 6 | 4 | vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } |
|
| 7 | - | ||
| 8 | - | local opt = vim.opt |
|
| 9 | - | ||
| 10 | 5 | vim.opt.swapfile = false |
|
| 11 | - | opt.autowrite = true -- Enable auto write |
|
| 12 | - | opt.clipboard = "unnamedplus" -- Sync with system clipboard |
|
| 13 | - | opt.completeopt = "menu,menuone,noselect" |
|
| 14 | - | opt.conceallevel = 3 -- Hide * markup for bold and italic |
|
| 15 | - | opt.confirm = true -- Confirm to save changes before exiting modified buffer |
|
| 16 | - | opt.cursorline = true -- Enable highlighting of the current line |
|
| 17 | - | opt.expandtab = true -- Use spaces instead of tabs |
|
| 18 | - | opt.formatoptions = "jcroqlnt" -- tcqj |
|
| 19 | - | opt.grepformat = "%f:%l:%c:%m" |
|
| 20 | - | opt.grepprg = "rg --vimgrep" |
|
| 21 | - | opt.ignorecase = true -- Ignore case |
|
| 22 | - | opt.inccommand = "nosplit" -- preview incremental substitute |
|
| 23 | - | opt.incsearch = true |
|
| 24 | - | opt.laststatus = 3 -- global statusline |
|
| 25 | - | opt.list = true -- Show some invisible characters (tabs... |
|
| 26 | - | opt.mouse = "a" -- Enable mouse mode |
|
| 27 | - | opt.number = true -- Print line number |
|
| 28 | - | opt.pumblend = 10 -- Popup blend |
|
| 29 | - | opt.pumheight = 10 -- Maximum number of entries in a popup |
|
| 30 | - | opt.relativenumber = true -- Relative line numbers |
|
| 31 | - | opt.scrolloff = 4 -- Lines of context |
|
| 32 | - | opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" } |
|
| 33 | - | opt.shiftround = true -- Round indent |
|
| 34 | - | opt.shiftwidth = 2 -- Size of an indent |
|
| 35 | - | opt.shortmess:append({ W = true, I = true, c = true, C = true }) |
|
| 36 | - | opt.showmode = false -- Dont show mode since we have a statusline |
|
| 37 | - | opt.sidescrolloff = 8 -- Columns of context |
|
| 38 | - | opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time |
|
| 39 | - | opt.smartcase = true -- Don't ignore case with capitals |
|
| 40 | - | opt.smartindent = true -- Insert indents automatically |
|
| 41 | - | opt.spelllang = { "en" } |
|
| 42 | - | opt.splitbelow = true -- Put new windows below current |
|
| 43 | - | opt.splitkeep = "screen" |
|
| 44 | - | opt.splitright = true -- Put new windows right of current |
|
| 45 | - | opt.tabstop = 2 -- Number of spaces tabs count for |
|
| 46 | - | opt.termguicolors = true -- True color support |
|
| 47 | - | opt.timeoutlen = 300 |
|
| 48 | - | opt.undofile = true |
|
| 49 | - | opt.undolevels = 10000 |
|
| 50 | - | opt.updatetime = 200 -- Save swap file and trigger CursorHold |
|
| 51 | - | opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode |
|
| 52 | - | opt.wildmode = "longest:full,full" -- Command-line completion mode |
|
| 53 | - | opt.winminwidth = 5 -- Minimum window width |
|
| 54 | - | opt.wrap = false -- Disable line wrap |
|
| 55 | - | opt.fillchars = { |
|
| 6 | + | vim.opt.autowrite = true -- Enable auto write |
|
| 7 | + | vim.opt.clipboard = "unnamedplus" -- Sync with system clipboard |
|
| 8 | + | vim.opt.completeopt = "menu,menuone,noselect" |
|
| 9 | + | vim.opt.conceallevel = 3 -- Hide * markup for bold and italic |
|
| 10 | + | vim.opt.confirm = true -- Confirm to save changes before exiting modified buffer |
|
| 11 | + | vim.opt.cursorline = true -- Enable highlighting of the current line |
|
| 12 | + | vim.opt.expandtab = true -- Use spaces instead of tabs |
|
| 13 | + | vim.opt.formatoptions = "jcroqlnt" -- tcqj |
|
| 14 | + | vim.opt.grepformat = "%f:%l:%c:%m" |
|
| 15 | + | vim.opt.grepprg = "rg --vimgrep" |
|
| 16 | + | vim.opt.ignorecase = true -- Ignore case |
|
| 17 | + | vim.opt.inccommand = "nosplit" -- preview incremental substitute |
|
| 18 | + | vim.opt.incsearch = true |
|
| 19 | + | vim.opt.laststatus = 3 -- global statusline |
|
| 20 | + | vim.opt.list = true -- Show some invisible characters (tabs... |
|
| 21 | + | vim.opt.mouse = "a" -- Enable mouse mode |
|
| 22 | + | vim.opt.number = true -- Print line number |
|
| 23 | + | vim.opt.pumblend = 10 -- Popup blend |
|
| 24 | + | vim.opt.pumheight = 10 -- Maximum number of entries in a popup |
|
| 25 | + | vim.opt.relativenumber = true -- Relative line numbers |
|
| 26 | + | vim.opt.scrolloff = 4 -- Lines of context |
|
| 27 | + | vim.opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" } |
|
| 28 | + | vim.opt.shiftround = true -- Round indent |
|
| 29 | + | vim.opt.shiftwidth = 2 -- Size of an indent |
|
| 30 | + | vim.opt.shortmess:append({ W = true, I = true, c = true, C = true }) |
|
| 31 | + | vim.opt.showmode = false -- Dont show mode since we have a statusline |
|
| 32 | + | vim.opt.sidescrolloff = 8 -- Columns of context |
|
| 33 | + | vim.opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time |
|
| 34 | + | vim.opt.smartcase = true -- Don't ignore case with capitals |
|
| 35 | + | vim.opt.smartindent = true -- Insert indents automatically |
|
| 36 | + | vim.opt.spell = true |
|
| 37 | + | vim.opt.spelllang = { "en" } |
|
| 38 | + | vim.opt.splitbelow = true -- Put new windows below current |
|
| 39 | + | vim.opt.splitkeep = "screen" |
|
| 40 | + | vim.opt.splitright = true -- Put new windows right of current |
|
| 41 | + | vim.opt.tabstop = 2 -- Number of spaces tabs count for |
|
| 42 | + | vim.opt.termguicolors = true -- True color support |
|
| 43 | + | vim.opt.timeoutlen = 300 |
|
| 44 | + | vim.opt.undofile = true |
|
| 45 | + | vim.opt.undolevels = 10000 |
|
| 46 | + | vim.opt.updatetime = 200 -- Save swap file and trigger CursorHold |
|
| 47 | + | vim.opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode |
|
| 48 | + | vim.opt.wildmode = "longest:full,full" -- Command-line completion mode |
|
| 49 | + | vim.opt.winminwidth = 5 -- Minimum window width |
|
| 50 | + | vim.opt.wrap = false -- Disable line wrap |
|
| 51 | + | vim.opt.fillchars = { |
|
| 56 | 52 | foldopen = "", |
|
| 57 | 53 | foldclose = "", |
|
| 58 | - | -- fold = "⸱", |
|
| 59 | 54 | fold = " ", |
|
| 60 | 55 | foldsep = " ", |
|
| 61 | 56 | diff = "╱", |
|
| 62 | 57 | eob = " ", |
|
| 63 | 58 | } |
|
| 64 | - | opt.list = false |
|
| 59 | + | vim.opt.list = false |
|
| 65 | 60 | ||
| 66 | 61 | if vim.fn.has("nvim-0.10") == 1 then |
|
| 67 | - | opt.smoothscroll = true |
|
| 62 | + | vim.opt.smoothscroll = true |
|
| 68 | 63 | end |
|
| 69 | 64 | ||
| 70 | 65 | -- Fix markdown indentation settings |
| 1 | - | return { |
|
| 2 | - | "stevedylandev/ai.vim", |
|
| 3 | - | lazy = false, |
|
| 4 | - | priority = 1000, |
|
| 5 | - | } |
|
| 6 | - |
| 1 | 1 | return { |
|
| 2 | 2 | 'echasnovski/mini.nvim', |
|
| 3 | 3 | version = '*', |
|
| 4 | + | dependencies = { 'rafamadriz/friendly-snippets' }, |
|
| 4 | 5 | config = function() |
|
| 5 | 6 | local win_config = function() |
|
| 6 | 7 | local height = math.floor(0.618 * vim.o.lines) |
|
| 46 | 47 | gen_loader.from_lang(), |
|
| 47 | 48 | }, |
|
| 48 | 49 | }) |
|
| 50 | + | MiniSnippets.start_lsp_server() |
|
| 49 | 51 | ||
| 50 | 52 | require('mini.files').setup({ |
|
| 51 | 53 | mappings = { |
|
| 53 | 55 | go_in_plus = '<CR>' |
|
| 54 | 56 | } |
|
| 55 | 57 | }) |
|
| 58 | + | ||
| 59 | + | require('mini.icons').setup() |
|
| 60 | + | vim.api.nvim_set_hl(0, 'MiniIconsAzure', { fg = vim.g.terminal_color_12 }) |
|
| 61 | + | vim.api.nvim_set_hl(0, 'MiniIconsBlue', { fg = vim.g.terminal_color_4 }) |
|
| 62 | + | vim.api.nvim_set_hl(0, 'MiniIconsCyan', { fg = vim.g.terminal_color_6 }) |
|
| 63 | + | vim.api.nvim_set_hl(0, 'MiniIconsGreen', { fg = vim.g.terminal_color_2 }) |
|
| 64 | + | vim.api.nvim_set_hl(0, 'MiniIconsGrey', { fg = vim.g.terminal_color_8 }) |
|
| 65 | + | vim.api.nvim_set_hl(0, 'MiniIconsOrange', { fg = vim.g.terminal_color_3 }) |
|
| 66 | + | vim.api.nvim_set_hl(0, 'MiniIconsPurple', { fg = vim.g.terminal_color_5 }) |
|
| 67 | + | vim.api.nvim_set_hl(0, 'MiniIconsRed', { fg = vim.g.terminal_color_1 }) |
|
| 68 | + | vim.api.nvim_set_hl(0, 'MiniIconsYellow', { fg = vim.g.terminal_color_11 }) |
|
| 56 | 69 | ||
| 57 | 70 | require('mini.surround').setup({ |
|
| 58 | 71 | mappings = { |
|
| 1 | + | local opts = { noremap = true, silent = true } |
|
| 2 | + | ||
| 1 | 3 | return { |
|
| 2 | 4 | "christoomey/vim-tmux-navigator", |
|
| 3 | 5 | config = function() |