diff options
Diffstat (limited to 'vim')
| -rw-r--r-- | vim/init/keymaps.vim | 5 | ||||
| -rw-r--r-- | vim/mini.lua | 405 |
2 files changed, 311 insertions, 99 deletions
diff --git a/vim/init/keymaps.vim b/vim/init/keymaps.vim index d456791..a6f75e5 100644 --- a/vim/init/keymaps.vim +++ b/vim/init/keymaps.vim | |||
| @@ -216,11 +216,12 @@ vnoremap <space> :<C-u>call AddSpaceForSelection()<CR> | |||
| 216 | " }}} | 216 | " }}} |
| 217 | " SEARCH/SUBSTITUTE {{{ | 217 | " SEARCH/SUBSTITUTE {{{ |
| 218 | 218 | ||
| 219 | |||
| 219 | " Search for selected test | 220 | " Search for selected test |
| 220 | vnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR> | 221 | vnoremap * y/\V<C-R>=escape(@",'/\')<CR><CR> |
| 221 | 222 | ||
| 222 | nnoremap g/ gv<esc>/\%V | 223 | nnoremap g/ gv<esc>/\%V |
| 223 | vnoremap g/ <esc>/\%V | 224 | vnoremap / <esc>/\%V |
| 224 | 225 | ||
| 225 | " Substitue across file | 226 | " Substitue across file |
| 226 | vnoremap <leader>s y:%s//<C-R>0/g<LEFT><LEFT> | 227 | vnoremap <leader>s y:%s//<C-R>0/g<LEFT><LEFT> |
| @@ -762,6 +763,8 @@ nnoremap <C-t>b <Cmd>TigBlame<CR> | |||
| 762 | " }}} | 763 | " }}} |
| 763 | " Tmp: Common system command {{{ | 764 | " Tmp: Common system command {{{ |
| 764 | 765 | ||
| 766 | nnoremap ! :r ! | ||
| 767 | |||
| 765 | " Show date selector | 768 | " Show date selector |
| 766 | nnoremap <leader>dd :r !sh -c 'LANG=en zenity --calendar --date-format="\%Y.\%m.\%d" 2>/dev/null'<CR><CR> | 769 | nnoremap <leader>dd :r !sh -c 'LANG=en zenity --calendar --date-format="\%Y.\%m.\%d" 2>/dev/null'<CR><CR> |
| 767 | nnoremap <leader>dD :r !sh -c 'LANG=en zenity --calendar --date-format="\%a \%b \%d" 2>/dev/null'<CR><CR> | 770 | nnoremap <leader>dD :r !sh -c 'LANG=en zenity --calendar --date-format="\%a \%b \%d" 2>/dev/null'<CR><CR> |
diff --git a/vim/mini.lua b/vim/mini.lua index d449bf7..6f7ba57 100644 --- a/vim/mini.lua +++ b/vim/mini.lua | |||
| @@ -38,7 +38,7 @@ Add, Now, Later = MiniDeps.add, MiniDeps.now, MiniDeps.later | |||
| 38 | require("mini.misc").setup({ | 38 | require("mini.misc").setup({ |
| 39 | make_global = { "put", "put_text", "zoom" }, | 39 | make_global = { "put", "put_text", "zoom" }, |
| 40 | }) | 40 | }) |
| 41 | vim.keymap.set( 'n', '<leader>Z', function() | 41 | vim.keymap.set('n', '<leader>Z', function() |
| 42 | zoom() | 42 | zoom() |
| 43 | vim.cmd("silent! call ToggleWinPadding()") | 43 | vim.cmd("silent! call ToggleWinPadding()") |
| 44 | end, { buffer = bufnr, desc = 'zoom' }) | 44 | end, { buffer = bufnr, desc = 'zoom' }) |
| @@ -114,13 +114,13 @@ require("mini.comment").setup({ | |||
| 114 | -- Toggle comment (like `gcip` - comment inner paragraph) for both | 114 | -- Toggle comment (like `gcip` - comment inner paragraph) for both |
| 115 | -- Normal and Visual modes | 115 | -- Normal and Visual modes |
| 116 | comment = "gc", | 116 | comment = "gc", |
| 117 | -- | 117 | |
| 118 | -- Toggle comment on current line | 118 | -- Toggle comment on current line |
| 119 | comment_line = "<C-/>", | 119 | comment_line = "<C-/>", |
| 120 | -- | 120 | |
| 121 | -- Toggle comment on visual selection | 121 | -- Toggle comment on visual selection |
| 122 | comment_visual = "<C-/>", | 122 | comment_visual = "<C-/>", |
| 123 | -- | 123 | |
| 124 | -- Define 'comment' textobject (like `dgc` - delete whole comment block) | 124 | -- Define 'comment' textobject (like `dgc` - delete whole comment block) |
| 125 | -- Works also in Visual mode if mapping differs from `comment_visual` | 125 | -- Works also in Visual mode if mapping differs from `comment_visual` |
| 126 | textobject = "gc", | 126 | textobject = "gc", |
| @@ -136,10 +136,10 @@ require("mini.diff").setup({ | |||
| 136 | -- Visualization style. Possible values are 'sign' and 'number'. | 136 | -- Visualization style. Possible values are 'sign' and 'number'. |
| 137 | -- Default: 'number' if line numbers are enabled, 'sign' otherwise. | 137 | -- Default: 'number' if line numbers are enabled, 'sign' otherwise. |
| 138 | style = "sign", | 138 | style = "sign", |
| 139 | -- | 139 | |
| 140 | -- Signs used for hunks with 'sign' view | 140 | -- Signs used for hunks with 'sign' view |
| 141 | signs = { add = "+", change = "▒", delete = "-" }, | 141 | signs = { add = "+", change = "▒", delete = "-" }, |
| 142 | -- | 142 | |
| 143 | -- Priority of used visualization extmarks | 143 | -- Priority of used visualization extmarks |
| 144 | priority = 199, | 144 | priority = 199, |
| 145 | }, | 145 | }, |
| @@ -191,7 +191,7 @@ hipatterns.setup({ | |||
| 191 | hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, | 191 | hack = { pattern = "%f[%w]()HACK()%f[%W]", group = "MiniHipatternsHack" }, |
| 192 | todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, | 192 | todo = { pattern = "%f[%w]()TODO()%f[%W]", group = "MiniHipatternsTodo" }, |
| 193 | note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, | 193 | note = { pattern = "%f[%w]()NOTE()%f[%W]", group = "MiniHipatternsNote" }, |
| 194 | -- | 194 | |
| 195 | -- Highlight hex color strings (`#rrggbb`) using that color | 195 | -- Highlight hex color strings (`#rrggbb`) using that color |
| 196 | hex_color = hipatterns.gen_highlighter.hex_color(), | 196 | hex_color = hipatterns.gen_highlighter.hex_color(), |
| 197 | }, | 197 | }, |
| @@ -205,7 +205,7 @@ end, { buffer = bufnr, desc = "Toggle hex color highlight" }) | |||
| 205 | require("mini.pairs").setup() | 205 | require("mini.pairs").setup() |
| 206 | -- }}} | 206 | -- }}} |
| 207 | -- -- mini.statusline {{{ | 207 | -- -- mini.statusline {{{ |
| 208 | -- -- | 208 | -- |
| 209 | -- require("mini.statusline").setup({ | 209 | -- require("mini.statusline").setup({ |
| 210 | -- content = { | 210 | -- content = { |
| 211 | -- active = status_config, | 211 | -- active = status_config, |
| @@ -351,16 +351,16 @@ Add { | |||
| 351 | -- }}} | 351 | -- }}} |
| 352 | -- vim-livedown {{{ | 352 | -- vim-livedown {{{ |
| 353 | Add { | 353 | Add { |
| 354 | source ='shime/vim-livedown' | 354 | source = 'shime/vim-livedown' |
| 355 | } | 355 | } |
| 356 | vim.keymap.set( 'n', '<F10>', ":LivedownToggle<CR>", { buffer = bufnr, desc = '' }) | 356 | vim.keymap.set('n', '<F10>', ":LivedownToggle<CR>", { buffer = bufnr, desc = '' }) |
| 357 | -- }}} | 357 | -- }}} |
| 358 | -- Preview Image {{{ | 358 | -- Preview Image {{{ |
| 359 | Add { | 359 | Add { |
| 360 | source = 'qaiviq/vim-imager' | 360 | source = 'qaiviq/vim-imager' |
| 361 | } | 361 | } |
| 362 | vim.cmd("let g:imager#filetypes = ['.md']") | 362 | vim.cmd("let g:imager#filetypes = ['.md']") |
| 363 | vim.keymap.set( 'n', '\\i', ":ToggleImages<CR>", { buffer = bufnr, desc = '' }) | 363 | vim.keymap.set('n', '\\i', ":ToggleImages<CR>", { buffer = bufnr, desc = '' }) |
| 364 | -- }}} | 364 | -- }}} |
| 365 | 365 | ||
| 366 | 366 | ||
| @@ -371,11 +371,11 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then | |||
| 371 | local lazyrepo = "https://github.com/folke/lazy.nvim.git" | 371 | local lazyrepo = "https://github.com/folke/lazy.nvim.git" |
| 372 | vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) | 372 | vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) |
| 373 | end | 373 | end |
| 374 | vim.cmd("set rtp+="..lazypath) | 374 | vim.cmd("set rtp+=" .. lazypath) |
| 375 | -- }}} | 375 | -- }}} |
| 376 | require("lazy").setup({ | 376 | require("lazy").setup({ |
| 377 | -- "tpope/vim-sleuth", | 377 | -- "tpope/vim-sleuth", |
| 378 | -- bufferline {{{ | 378 | -- bufferline {{{ |
| 379 | { | 379 | { |
| 380 | "akinsho/bufferline.nvim", | 380 | "akinsho/bufferline.nvim", |
| 381 | lazy = false, | 381 | lazy = false, |
| @@ -384,7 +384,7 @@ require("lazy").setup({ | |||
| 384 | "tiagovla/scope.nvim", | 384 | "tiagovla/scope.nvim", |
| 385 | }, | 385 | }, |
| 386 | config = function() | 386 | config = function() |
| 387 | require('bufferline').setup{ | 387 | require('bufferline').setup { |
| 388 | options = { | 388 | options = { |
| 389 | numbers = 'ordinal', | 389 | numbers = 'ordinal', |
| 390 | tab_size = 14, | 390 | tab_size = 14, |
| @@ -428,7 +428,7 @@ require("lazy").setup({ | |||
| 428 | text_align = "right" | 428 | text_align = "right" |
| 429 | } | 429 | } |
| 430 | }, | 430 | }, |
| 431 | custom_filter = function (buf_number) | 431 | custom_filter = function(buf_number) |
| 432 | if vim.t.bufs == nil then return false end | 432 | if vim.t.bufs == nil then return false end |
| 433 | for _, p in ipairs(vim.t.bufs) do | 433 | for _, p in ipairs(vim.t.bufs) do |
| 434 | if p == buf_number then | 434 | if p == buf_number then |
| @@ -522,7 +522,7 @@ require("lazy").setup({ | |||
| 522 | }, | 522 | }, |
| 523 | }, | 523 | }, |
| 524 | lualine_y = { | 524 | lualine_y = { |
| 525 | { "progress", separator = " ", padding = { left = 1, right = 0 } }, | 525 | { "progress", separator = " ", padding = { left = 1, right = 0 } }, |
| 526 | { "location", padding = { left = 0, right = 1 } }, | 526 | { "location", padding = { left = 0, right = 1 } }, |
| 527 | }, | 527 | }, |
| 528 | lualine_z = { | 528 | lualine_z = { |
| @@ -539,7 +539,7 @@ require("lazy").setup({ | |||
| 539 | config = function() | 539 | config = function() |
| 540 | require('lualine').setup(opts) | 540 | require('lualine').setup(opts) |
| 541 | if vim.o.lines < 20 then | 541 | if vim.o.lines < 20 then |
| 542 | vim.o.laststatus=0 | 542 | vim.o.laststatus = 0 |
| 543 | end | 543 | end |
| 544 | end | 544 | end |
| 545 | }, | 545 | }, |
| @@ -564,11 +564,11 @@ require("lazy").setup({ | |||
| 564 | require("telescope").setup({ | 564 | require("telescope").setup({ |
| 565 | defaults = { | 565 | defaults = { |
| 566 | preview = { | 566 | preview = { |
| 567 | filesize_hook = function(filepath, bufnr, opts) | 567 | filesize_hook = function(filepath, bufnr, opts) |
| 568 | local max_bytes = 100000 | 568 | local max_bytes = 100000 |
| 569 | local cmd = {"head", "-c", max_bytes, filepath} | 569 | local cmd = { "head", "-c", max_bytes, filepath } |
| 570 | require('telescope.previewers.utils').job_maker(cmd, bufnr, opts) | 570 | require('telescope.previewers.utils').job_maker(cmd, bufnr, opts) |
| 571 | end | 571 | end |
| 572 | }, | 572 | }, |
| 573 | mappings = { | 573 | mappings = { |
| 574 | i = { | 574 | i = { |
| @@ -612,17 +612,17 @@ require("lazy").setup({ | |||
| 612 | }, | 612 | }, |
| 613 | extensions = { | 613 | extensions = { |
| 614 | fzf = { | 614 | fzf = { |
| 615 | fuzzy = true, -- false will only do exact matching | 615 | fuzzy = true, -- false will only do exact matching |
| 616 | override_generic_sorter = true, -- override the generic sorter | 616 | override_generic_sorter = true, -- override the generic sorter |
| 617 | override_file_sorter = true, -- override the file sorter | 617 | override_file_sorter = true, -- override the file sorter |
| 618 | case_mode = "smart_case", -- or "ignore_case" or "respect_case" | 618 | case_mode = "smart_case", -- or "ignore_case" or "respect_case" |
| 619 | -- the default case_mode is "smart_case" | 619 | -- the default case_mode is "smart_case" |
| 620 | }, | 620 | }, |
| 621 | aerial = { | 621 | aerial = { |
| 622 | -- Display symbols as <root>.<parent>.<symbol> | 622 | -- Display symbols as <root>.<parent>.<symbol> |
| 623 | show_nesting = { | 623 | show_nesting = { |
| 624 | ["_"] = false, -- This key will be the default | 624 | ["_"] = false, -- This key will be the default |
| 625 | json = true, -- You can set the option for specific filetypes | 625 | json = true, -- You can set the option for specific filetypes |
| 626 | yaml = true, | 626 | yaml = true, |
| 627 | }, | 627 | }, |
| 628 | }, | 628 | }, |
| @@ -653,7 +653,7 @@ require("lazy").setup({ | |||
| 653 | vim.keymap.set("n", "<leader>tt", "<cmd>Telescope<CR>", { desc = "telescope help page" }) | 653 | vim.keymap.set("n", "<leader>tt", "<cmd>Telescope<CR>", { desc = "telescope help page" }) |
| 654 | vim.keymap.set("n", "<leader>sk", "<cmd>Telescope keymaps<CR>", { desc = "telescope keymaps" }) | 654 | vim.keymap.set("n", "<leader>sk", "<cmd>Telescope keymaps<CR>", { desc = "telescope keymaps" }) |
| 655 | vim.keymap.set("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "telescope pick hidden term" }) | 655 | vim.keymap.set("n", "<leader>pt", "<cmd>Telescope terms<CR>", { desc = "telescope pick hidden term" }) |
| 656 | -- | 656 | |
| 657 | vim.keymap.set("n", "<leader>ss", function() | 657 | vim.keymap.set("n", "<leader>ss", function() |
| 658 | local current_filetype = vim.bo.filetype | 658 | local current_filetype = vim.bo.filetype |
| 659 | local cwd = os.getenv("HOME") .. "/snippets" | 659 | local cwd = os.getenv("HOME") .. "/snippets" |
| @@ -672,7 +672,7 @@ require("lazy").setup({ | |||
| 672 | return current_picker:_get_prompt() | 672 | return current_picker:_get_prompt() |
| 673 | end | 673 | end |
| 674 | end | 674 | end |
| 675 | -- | 675 | |
| 676 | local edit_snippet = function() | 676 | local edit_snippet = function() |
| 677 | local file = get_prompt_or_entry() | 677 | local file = get_prompt_or_entry() |
| 678 | require("telescope.actions").close(prompt_bufnr) | 678 | require("telescope.actions").close(prompt_bufnr) |
| @@ -683,7 +683,7 @@ require("lazy").setup({ | |||
| 683 | vim.bo.bufhidden = "wipe" | 683 | vim.bo.bufhidden = "wipe" |
| 684 | vim.cmd("set filetype?") | 684 | vim.cmd("set filetype?") |
| 685 | end | 685 | end |
| 686 | -- | 686 | |
| 687 | local insert_selected_snippet = function() | 687 | local insert_selected_snippet = function() |
| 688 | local file = get_prompt_or_entry() | 688 | local file = get_prompt_or_entry() |
| 689 | local path = cwd .. "/" .. file | 689 | local path = cwd .. "/" .. file |
| @@ -696,16 +696,16 @@ require("lazy").setup({ | |||
| 696 | edit_snippet() | 696 | edit_snippet() |
| 697 | end | 697 | end |
| 698 | end | 698 | end |
| 699 | -- | 699 | |
| 700 | map("i", "<CR>", insert_selected_snippet) | 700 | map("i", "<CR>", insert_selected_snippet) |
| 701 | map("i", "<C-T>", edit_snippet) | 701 | map("i", "<C-T>", edit_snippet) |
| 702 | map("n", "<CR>", insert_selected_snippet) | 702 | map("n", "<CR>", insert_selected_snippet) |
| 703 | -- | 703 | |
| 704 | return true | 704 | return true |
| 705 | end, | 705 | end, |
| 706 | }) | 706 | }) |
| 707 | end, { desc = "[S]earch [S]nippets" }) | 707 | end, { desc = "[S]earch [S]nippets" }) |
| 708 | -- | 708 | |
| 709 | vim.keymap.set("n", "<leader>sd", function() | 709 | vim.keymap.set("n", "<leader>sd", function() |
| 710 | require("telescope.builtin").oldfiles({ | 710 | require("telescope.builtin").oldfiles({ |
| 711 | prompt_title = "CD to", | 711 | prompt_title = "CD to", |
| @@ -716,10 +716,10 @@ require("lazy").setup({ | |||
| 716 | require("telescope.actions").close(prompt_bufnr) | 716 | require("telescope.actions").close(prompt_bufnr) |
| 717 | vim.api.nvim_feedkeys(":cd " .. path, "n", true) | 717 | vim.api.nvim_feedkeys(":cd " .. path, "n", true) |
| 718 | end | 718 | end |
| 719 | -- | 719 | |
| 720 | map("i", "<CR>", cd_prompt) | 720 | map("i", "<CR>", cd_prompt) |
| 721 | map("n", "<CR>", cd_prompt) | 721 | map("n", "<CR>", cd_prompt) |
| 722 | -- | 722 | |
| 723 | return true | 723 | return true |
| 724 | end, | 724 | end, |
| 725 | }) | 725 | }) |
| @@ -768,7 +768,7 @@ require("lazy").setup({ | |||
| 768 | root_folder_label = false, | 768 | root_folder_label = false, |
| 769 | highlight_git = true, | 769 | highlight_git = true, |
| 770 | highlight_opened_files = "none", | 770 | highlight_opened_files = "none", |
| 771 | -- | 771 | |
| 772 | indent_markers = { | 772 | indent_markers = { |
| 773 | enable = true, | 773 | enable = true, |
| 774 | }, | 774 | }, |
| @@ -877,7 +877,7 @@ require("lazy").setup({ | |||
| 877 | end, | 877 | end, |
| 878 | }, | 878 | }, |
| 879 | --}}} | 879 | --}}} |
| 880 | -- Markdown: obsidian {{{ | 880 | -- Markdown: obsidian {{{ |
| 881 | { | 881 | { |
| 882 | "epwalsh/obsidian.nvim", | 882 | "epwalsh/obsidian.nvim", |
| 883 | version = "*", -- recommended, use latest release instead of latest commit | 883 | version = "*", -- recommended, use latest release instead of latest commit |
| @@ -895,12 +895,12 @@ require("lazy").setup({ | |||
| 895 | "nvim-lua/plenary.nvim", | 895 | "nvim-lua/plenary.nvim", |
| 896 | }, | 896 | }, |
| 897 | config = function() | 897 | config = function() |
| 898 | vim.keymap.set("n", "<leader>oo", ":Obsidian", { }) | 898 | vim.keymap.set("n", "<leader>oo", ":Obsidian", {}) |
| 899 | vim.keymap.set("n", "<leader>ot", ":ObsidianTags<CR>", { }) | 899 | vim.keymap.set("n", "<leader>ot", ":ObsidianTags<CR>", {}) |
| 900 | vim.keymap.set("n", "<leader>os", ":ObsidianSearch<CR>", { }) | 900 | vim.keymap.set("n", "<leader>os", ":ObsidianSearch<CR>", {}) |
| 901 | vim.keymap.set("n", "<leader>oq", ":ObsidianQuickSwitch<CR>", { }) | 901 | vim.keymap.set("n", "<leader>oq", ":ObsidianQuickSwitch<CR>", {}) |
| 902 | vim.keymap.set("v", "<leader>on", ":ObsidianLinkNew<CR>", { }) | 902 | vim.keymap.set("v", "<leader>on", ":ObsidianLinkNew<CR>", {}) |
| 903 | vim.keymap.set("n", "<leader>ol", ":ObsidianLinks<CR>", { }) | 903 | vim.keymap.set("n", "<leader>ol", ":ObsidianLinks<CR>", {}) |
| 904 | require("obsidian").setup({ | 904 | require("obsidian").setup({ |
| 905 | workspaces = { | 905 | workspaces = { |
| 906 | { | 906 | { |
| @@ -961,8 +961,8 @@ require("lazy").setup({ | |||
| 961 | }) | 961 | }) |
| 962 | end, | 962 | end, |
| 963 | }, | 963 | }, |
| 964 | -- }}} | 964 | -- }}} |
| 965 | -- Markdown: preview {{{ | 965 | -- Markdown: preview {{{ |
| 966 | { | 966 | { |
| 967 | "iamcco/markdown-preview.nvim", | 967 | "iamcco/markdown-preview.nvim", |
| 968 | cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, | 968 | cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, |
| @@ -982,7 +982,7 @@ require("lazy").setup({ | |||
| 982 | vim.g.mkdp_browser = 'firefox' | 982 | vim.g.mkdp_browser = 'firefox' |
| 983 | end, | 983 | end, |
| 984 | }, | 984 | }, |
| 985 | -- }}} | 985 | -- }}} |
| 986 | -- markview.nvim {{{ | 986 | -- markview.nvim {{{ |
| 987 | { | 987 | { |
| 988 | "OXY2DEV/markview.nvim", | 988 | "OXY2DEV/markview.nvim", |
| @@ -997,7 +997,7 @@ require("lazy").setup({ | |||
| 997 | "nvim-tree/nvim-web-devicons" | 997 | "nvim-tree/nvim-web-devicons" |
| 998 | }, | 998 | }, |
| 999 | config = function() | 999 | config = function() |
| 1000 | vim.keymap.set( 'n', '\\m', ":Markview<CR>", { buffer = bufnr, desc = '' }) | 1000 | vim.keymap.set('n', '\\m', ":Markview<CR>", { buffer = bufnr, desc = '' }) |
| 1001 | end | 1001 | end |
| 1002 | }, | 1002 | }, |
| 1003 | -- }}} | 1003 | -- }}} |
| @@ -1006,43 +1006,258 @@ require("lazy").setup({ | |||
| 1006 | -- Use :help lspconfig-all to check servers | 1006 | -- Use :help lspconfig-all to check servers |
| 1007 | { | 1007 | { |
| 1008 | "neovim/nvim-lspconfig", | 1008 | "neovim/nvim-lspconfig", |
| 1009 | dependencies = { | ||
| 1010 | -- Automatically install LSPs and related tools to stdpath for Neovim | ||
| 1011 | { 'williamboman/mason.nvim', config = true }, -- NOTE: Must be loaded before dependants | ||
| 1012 | 'williamboman/mason-lspconfig.nvim', | ||
| 1013 | 'WhoIsSethDaniel/mason-tool-installer.nvim', | ||
| 1014 | |||
| 1015 | -- Useful status updates for LSP. | ||
| 1016 | -- NOTE: `opts = {}` is the same as calling `require('fidget').setup({})` | ||
| 1017 | { 'j-hui/fidget.nvim', opts = {} }, | ||
| 1018 | |||
| 1019 | -- Allows extra capabilities provided by nvim-cmp | ||
| 1020 | 'hrsh7th/cmp-nvim-lsp', | ||
| 1021 | }, | ||
| 1009 | lazy = false, | 1022 | lazy = false, |
| 1010 | config = function() | 1023 | config = function() |
| 1011 | local lspconfig = require "lspconfig" | 1024 | -- Brief aside: **What is LSP?** |
| 1012 | -- | 1025 | -- |
| 1013 | -- typescript | 1026 | -- LSP is an initialism you've probably heard, but might not understand what it is. |
| 1014 | lspconfig.lua_ls.setup {} | ||
| 1015 | lspconfig.tsserver.setup {} | ||
| 1016 | lspconfig.vimls.setup {} | ||
| 1017 | lspconfig.html.setup {} | ||
| 1018 | -- | 1027 | -- |
| 1019 | vim.keymap.set("n", "<leader>F", function() | 1028 | -- LSP stands for Language Server Protocol. It's a protocol that helps editors |
| 1020 | vim.lsp.buf.format() | 1029 | -- and language tooling communicate in a standardized fashion. |
| 1021 | end, { desc = "format files" }) | 1030 | -- |
| 1022 | end, | 1031 | -- In general, you have a "server" which is some tool built to understand a particular |
| 1023 | }, | 1032 | -- language (such as `gopls`, `lua_ls`, `rust_analyzer`, etc.). These Language Servers |
| 1024 | -- }}} | 1033 | -- (sometimes called LSP servers, but that's kind of like ATM Machine) are standalone |
| 1025 | -- Mason {{{ | 1034 | -- processes that communicate with some "client" - in this case, Neovim! |
| 1026 | { | 1035 | -- |
| 1027 | "williamboman/mason.nvim", | 1036 | -- LSP provides Neovim with features like: |
| 1028 | dependencies = { | 1037 | -- - Go to definition |
| 1029 | "williamboman/mason-lspconfig.nvim", | 1038 | -- - Find references |
| 1030 | }, | 1039 | -- - Autocompletion |
| 1031 | config = function() | 1040 | -- - Symbol Search |
| 1041 | -- - and more! | ||
| 1042 | -- | ||
| 1043 | -- Thus, Language Servers are external tools that must be installed separately from | ||
| 1044 | -- Neovim. This is where `mason` and related plugins come into play. | ||
| 1045 | -- | ||
| 1046 | -- If you're wondering about lsp vs treesitter, you can check out the wonderfully | ||
| 1047 | -- and elegantly composed help section, `:help lsp-vs-treesitter` | ||
| 1048 | |||
| 1049 | -- This function gets run when an LSP attaches to a particular buffer. | ||
| 1050 | -- That is to say, every time a new file is opened that is associated with | ||
| 1051 | -- an lsp (for example, opening `main.rs` is associated with `rust_analyzer`) this | ||
| 1052 | -- function will be executed to configure the current buffer | ||
| 1053 | vim.api.nvim_create_autocmd('LspAttach', { | ||
| 1054 | group = vim.api.nvim_create_augroup('kickstart-lsp-attach', { clear = true }), | ||
| 1055 | callback = function(event) | ||
| 1056 | -- NOTE: Remember that Lua is a real programming language, and as such it is possible | ||
| 1057 | -- to define small helper and utility functions so you don't have to repeat yourself. | ||
| 1058 | -- | ||
| 1059 | -- In this case, we create a function that lets us more easily define mappings specific | ||
| 1060 | -- for LSP related items. It sets the mode, buffer and description for us each time. | ||
| 1061 | local map = function(keys, func, desc) | ||
| 1062 | vim.keymap.set('n', keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc }) | ||
| 1063 | end | ||
| 1064 | map("<leader>F", function() vim.lsp.buf.format() end, "Format files") -- Jump to the definition of the word under your cursor. | ||
| 1065 | |||
| 1066 | -- This is where a variable was first declared, or where a function is defined, etc. | ||
| 1067 | -- To jump back, press <C-t>. | ||
| 1068 | map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') | ||
| 1069 | |||
| 1070 | -- Find references for the word under your cursor. | ||
| 1071 | map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences') | ||
| 1072 | |||
| 1073 | -- Jump to the implementation of the word under your cursor. | ||
| 1074 | -- Useful when your language has ways of declaring types without an actual implementation. | ||
| 1075 | map('gI', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation') | ||
| 1076 | |||
| 1077 | -- Jump to the type of the word under your cursor. | ||
| 1078 | -- Useful when you're not sure what type a variable is and you want to see | ||
| 1079 | -- the definition of its *type*, not where it was *defined*. | ||
| 1080 | map('<leader>D', require('telescope.builtin').lsp_type_definitions, 'Type [D]efinition') | ||
| 1081 | |||
| 1082 | -- Fuzzy find all the symbols in your current document. | ||
| 1083 | -- Symbols are things like variables, functions, types, etc. | ||
| 1084 | map('<leader>ds', require('telescope.builtin').lsp_document_symbols, '[D]ocument [S]ymbols') | ||
| 1085 | |||
| 1086 | -- Fuzzy find all the symbols in your current workspace. | ||
| 1087 | -- Similar to document symbols, except searches over your entire project. | ||
| 1088 | map('<leader>ws', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols') | ||
| 1089 | |||
| 1090 | -- Rename the variable under your cursor. | ||
| 1091 | -- Most Language Servers support renaming across files, etc. | ||
| 1092 | map('<leader>rn', vim.lsp.buf.rename, '[R]e[n]ame') | ||
| 1093 | |||
| 1094 | -- Execute a code action, usually your cursor needs to be on top of an error | ||
| 1095 | -- or a suggestion from your LSP for this to activate. | ||
| 1096 | map('<leader>ca', vim.lsp.buf.code_action, '[C]ode [A]ction') | ||
| 1097 | |||
| 1098 | -- WARN: This is not Goto Definition, this is Goto Declaration. | ||
| 1099 | -- For example, in C this would take you to the header. | ||
| 1100 | map('gD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') | ||
| 1101 | |||
| 1102 | -- The following two autocommands are used to highlight references of the | ||
| 1103 | -- word under your cursor when your cursor rests there for a little while. | ||
| 1104 | -- See `:help CursorHold` for information about when this is executed | ||
| 1105 | -- | ||
| 1106 | -- When you move your cursor, the highlights will be cleared (the second autocommand). | ||
| 1107 | local client = vim.lsp.get_client_by_id(event.data.client_id) | ||
| 1108 | if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then | ||
| 1109 | local highlight_augroup = vim.api.nvim_create_augroup('kickstart-lsp-highlight', { clear = false }) | ||
| 1110 | vim.api.nvim_create_autocmd({ 'CursorHold', 'CursorHoldI' }, { | ||
| 1111 | buffer = event.buf, | ||
| 1112 | group = highlight_augroup, | ||
| 1113 | callback = vim.lsp.buf.document_highlight, | ||
| 1114 | }) | ||
| 1115 | |||
| 1116 | vim.api.nvim_create_autocmd({ 'CursorMoved', 'CursorMovedI' }, { | ||
| 1117 | buffer = event.buf, | ||
| 1118 | group = highlight_augroup, | ||
| 1119 | callback = vim.lsp.buf.clear_references, | ||
| 1120 | }) | ||
| 1121 | |||
| 1122 | vim.api.nvim_create_autocmd('LspDetach', { | ||
| 1123 | group = vim.api.nvim_create_augroup('kickstart-lsp-detach', { clear = true }), | ||
| 1124 | callback = function(event2) | ||
| 1125 | vim.lsp.buf.clear_references() | ||
| 1126 | vim.api.nvim_clear_autocmds { group = 'kickstart-lsp-highlight', buffer = event2.buf } | ||
| 1127 | end, | ||
| 1128 | }) | ||
| 1129 | end | ||
| 1130 | |||
| 1131 | -- The following code creates a keymap to toggle inlay hints in your | ||
| 1132 | -- code, if the language server you are using supports them | ||
| 1133 | -- | ||
| 1134 | -- This may be unwanted, since they displace some of your code | ||
| 1135 | if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_inlayHint) then | ||
| 1136 | map('<leader>th', function() | ||
| 1137 | vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled { bufnr = event.buf }) | ||
| 1138 | end, '[T]oggle Inlay [H]ints') | ||
| 1139 | end | ||
| 1140 | end, | ||
| 1141 | }) | ||
| 1142 | |||
| 1143 | -- LSP servers and clients are able to communicate to each other what features they support. | ||
| 1144 | -- By default, Neovim doesn't support everything that is in the LSP specification. | ||
| 1145 | -- When you add nvim-cmp, luasnip, etc. Neovim now has *more* capabilities. | ||
| 1146 | -- So, we create new capabilities with nvim cmp, and then broadcast that to the servers. | ||
| 1147 | local capabilities = vim.lsp.protocol.make_client_capabilities() | ||
| 1148 | capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities()) | ||
| 1149 | |||
| 1150 | -- Enable the following language servers | ||
| 1151 | -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. | ||
| 1152 | -- | ||
| 1153 | -- Add any additional override configuration in the following tables. Available keys are: | ||
| 1154 | -- - cmd (table): Override the default command used to start the server | ||
| 1155 | -- - filetypes (table): Override the default list of associated filetypes for the server | ||
| 1156 | -- - capabilities (table): Override fields in capabilities. Can be used to disable certain LSP features. | ||
| 1157 | -- - settings (table): Override the default settings passed when initializing the server. | ||
| 1158 | -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ | ||
| 1159 | local servers = { | ||
| 1160 | -- clangd = {}, | ||
| 1161 | -- gopls = {}, | ||
| 1162 | -- pyright = {}, | ||
| 1163 | -- rust_analyzer = {}, | ||
| 1164 | -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs | ||
| 1165 | -- | ||
| 1166 | -- Some languages (like typescript) have entire language plugins that can be useful: | ||
| 1167 | -- https://github.com/pmizio/typescript-tools.nvim | ||
| 1168 | -- | ||
| 1169 | -- But for many setups, the LSP (`tsserver`) will work just fine | ||
| 1170 | -- tsserver = {}, | ||
| 1171 | -- | ||
| 1172 | vimls = {}, | ||
| 1173 | |||
| 1174 | lua_ls = { | ||
| 1175 | -- cmd = {...}, | ||
| 1176 | -- filetypes = { ...}, | ||
| 1177 | -- capabilities = {}, | ||
| 1178 | settings = { | ||
| 1179 | Lua = { | ||
| 1180 | completion = { | ||
| 1181 | callSnippet = 'Replace', | ||
| 1182 | }, | ||
| 1183 | -- You can toggle below to ignore Lua_LS's noisy `missing-fields` warnings | ||
| 1184 | -- diagnostics = { disable = { 'missing-fields' } }, | ||
| 1185 | }, | ||
| 1186 | }, | ||
| 1187 | }, | ||
| 1188 | } | ||
| 1189 | |||
| 1190 | -- Ensure the servers and tools above are installed | ||
| 1191 | -- To check the current status of installed tools and/or manually install | ||
| 1192 | -- other tools, you can run | ||
| 1193 | -- :Mason | ||
| 1194 | -- | ||
| 1195 | -- You can press `g?` for help in this menu. | ||
| 1032 | require('mason').setup { | 1196 | require('mason').setup { |
| 1033 | automatically_installation = true, | 1197 | automatically_installation = true, |
| 1034 | ensure_installed = { | 1198 | } |
| 1035 | "vim-language-server", | 1199 | |
| 1036 | "lua-language-server", | 1200 | -- You can add other tools here that you want Mason to install |
| 1037 | "css-lsp", | 1201 | -- for you, so that they are available from within Neovim. |
| 1038 | "html-lsp", | 1202 | local ensure_installed = vim.tbl_keys(servers or {}) |
| 1039 | "prettier", | 1203 | vim.list_extend(ensure_installed, { |
| 1040 | "stylua", | 1204 | 'stylua', -- Used to format Lua code |
| 1205 | }) | ||
| 1206 | require('mason-tool-installer').setup { ensure_installed = ensure_installed } | ||
| 1207 | |||
| 1208 | require('mason-lspconfig').setup { | ||
| 1209 | handlers = { | ||
| 1210 | function(server_name) | ||
| 1211 | local server = servers[server_name] or {} | ||
| 1212 | -- This handles overriding only values explicitly passed | ||
| 1213 | -- by the server configuration above. Useful when disabling | ||
| 1214 | -- certain features of an LSP (for example, turning off formatting for tsserver) | ||
| 1215 | server.capabilities = vim.tbl_deep_extend('force', {}, capabilities, server.capabilities or {}) | ||
| 1216 | require('lspconfig')[server_name].setup(server) | ||
| 1217 | end, | ||
| 1041 | }, | 1218 | }, |
| 1042 | } | 1219 | } |
| 1043 | end | 1220 | end, |
| 1044 | }, | 1221 | }, |
| 1045 | -- }}} | 1222 | -- }}} |
| 1223 | -- -- comfort {{{ | ||
| 1224 | -- { -- Autoformat | ||
| 1225 | -- 'stevearc/conform.nvim', | ||
| 1226 | -- event = { 'BufWritePre' }, | ||
| 1227 | -- cmd = { 'ConformInfo' }, | ||
| 1228 | -- keys = { | ||
| 1229 | -- { | ||
| 1230 | -- '<leader>F', | ||
| 1231 | -- function() | ||
| 1232 | -- require('conform').format { async = true, lsp_fallback = true } | ||
| 1233 | -- end, | ||
| 1234 | -- mode = '', | ||
| 1235 | -- desc = '[F]ormat buffer', | ||
| 1236 | -- }, | ||
| 1237 | -- }, | ||
| 1238 | -- opts = { | ||
| 1239 | -- notify_on_error = false, | ||
| 1240 | -- format_on_save = function(bufnr) | ||
| 1241 | -- -- Disable "format_on_save lsp_fallback" for languages that don't | ||
| 1242 | -- -- have a well standardized coding style. You can add additional | ||
| 1243 | -- -- languages here or re-enable it for the disabled ones. | ||
| 1244 | -- local disable_filetypes = { c = true, cpp = true } | ||
| 1245 | -- return { | ||
| 1246 | -- timeout_ms = 500, | ||
| 1247 | -- lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype], | ||
| 1248 | -- } | ||
| 1249 | -- end, | ||
| 1250 | -- formatters_by_ft = { | ||
| 1251 | -- lua = { 'stylua' }, | ||
| 1252 | -- -- Conform can also run multiple formatters sequentially | ||
| 1253 | -- -- python = { "isort", "black" }, | ||
| 1254 | -- -- | ||
| 1255 | -- -- You can use 'stop_after_first' to run the first available formatter from the list | ||
| 1256 | -- -- javascript = { "prettierd", "prettier", stop_after_first = true }, | ||
| 1257 | -- }, | ||
| 1258 | -- }, | ||
| 1259 | -- }, | ||
| 1260 | -- -- }}} | ||
| 1046 | -- treesitter {{{ | 1261 | -- treesitter {{{ |
| 1047 | { | 1262 | { |
| 1048 | "nvim-treesitter/nvim-treesitter", | 1263 | "nvim-treesitter/nvim-treesitter", |
| @@ -1068,12 +1283,6 @@ require("lazy").setup({ | |||
| 1068 | 1283 | ||
| 1069 | indent = { enable = true }, | 1284 | indent = { enable = true }, |
| 1070 | }) | 1285 | }) |
| 1071 | vim.cmd([[ | ||
| 1072 | syn match MarkdownHtmlDetails '^<details>' conceal cchar=▶ | ||
| 1073 | syn match MarkdownHtmlSummary '<summary>' conceal cchar= | ||
| 1074 | syn match MarkdownHtmlSummaryEnd '</summary>' conceal | ||
| 1075 | syn match MarkdownHtmlDetailsEnd '^</details>' conceal cchar=E | ||
| 1076 | ]]) | ||
| 1077 | end, | 1286 | end, |
| 1078 | }, | 1287 | }, |
| 1079 | -- }}} | 1288 | -- }}} |
| @@ -1103,7 +1312,7 @@ require("lazy").setup({ | |||
| 1103 | require("luasnip.loaders.from_vscode").lazy_load() | 1312 | require("luasnip.loaders.from_vscode").lazy_load() |
| 1104 | require("luasnip.loaders.from_lua").load() | 1313 | require("luasnip.loaders.from_lua").load() |
| 1105 | require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } | 1314 | require("luasnip.loaders.from_lua").lazy_load { paths = vim.g.lua_snippets_path or "" } |
| 1106 | -- | 1315 | |
| 1107 | vim.api.nvim_create_autocmd("InsertLeave", { | 1316 | vim.api.nvim_create_autocmd("InsertLeave", { |
| 1108 | callback = function() | 1317 | callback = function() |
| 1109 | if | 1318 | if |
| @@ -1116,7 +1325,7 @@ require("lazy").setup({ | |||
| 1116 | }) | 1325 | }) |
| 1117 | end, | 1326 | end, |
| 1118 | }, | 1327 | }, |
| 1119 | -- | 1328 | |
| 1120 | -- cmp sources plugins | 1329 | -- cmp sources plugins |
| 1121 | { | 1330 | { |
| 1122 | "hrsh7th/cmp-nvim-lua", | 1331 | "hrsh7th/cmp-nvim-lua", |
| @@ -1158,7 +1367,7 @@ require("lazy").setup({ | |||
| 1158 | formatting = { | 1367 | formatting = { |
| 1159 | format = require('lspkind').cmp_format({ | 1368 | format = require('lspkind').cmp_format({ |
| 1160 | with_text = true, -- do not show text alongside icons | 1369 | with_text = true, -- do not show text alongside icons |
| 1161 | maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) | 1370 | maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters) |
| 1162 | before = function(entry, vim_item) | 1371 | before = function(entry, vim_item) |
| 1163 | -- Source 显示提示来源 | 1372 | -- Source 显示提示来源 |
| 1164 | vim_item.menu = '<' .. entry.source.name .. '>' | 1373 | vim_item.menu = '<' .. entry.source.name .. '>' |
| @@ -1210,30 +1419,30 @@ require("lazy").setup({ | |||
| 1210 | 'nvim-treesitter/nvim-treesitter', -- optional | 1419 | 'nvim-treesitter/nvim-treesitter', -- optional |
| 1211 | 'nvim-tree/nvim-web-devicons', -- optional | 1420 | 'nvim-tree/nvim-web-devicons', -- optional |
| 1212 | }, | 1421 | }, |
| 1213 | config = function() | 1422 | config = function() |
| 1214 | require('lspsaga').setup({ | 1423 | require('lspsaga').setup({ |
| 1215 | autochdir = true, | 1424 | autochdir = true, |
| 1216 | }) | 1425 | }) |
| 1217 | vim.api.nvim_create_autocmd("LspAttach", { | 1426 | vim.api.nvim_create_autocmd("LspAttach", { |
| 1218 | group = custom_autocommands, | 1427 | group = custom_autocommands, |
| 1219 | pattern = "*", | 1428 | pattern = "*", |
| 1220 | callback = function(args) | 1429 | callback = function(args) |
| 1221 | local map = vim.api.nvim_buf_set_keymap | 1430 | local map = vim.api.nvim_buf_set_keymap |
| 1222 | map(0, "n", "gd", "<cmd>Lspsaga goto_definition<cr>", {silent = true, noremap = true}) | 1431 | map(0, "n", "gd", "<cmd>Lspsaga goto_definition<cr>", { silent = true, noremap = true }) |
| 1223 | map(0, "n", "gr", "<cmd>Lspsaga rename<cr>", {silent = true, noremap = true}) | 1432 | map(0, "n", "gR", "<cmd>Lspsaga rename<cr>", { silent = true, noremap = true }) |
| 1224 | map(0, "n", "gx", "<cmd>Lspsaga code_action<cr>", {silent = true, noremap = true}) | 1433 | map(0, "n", "gx", "<cmd>Lspsaga code_action<cr>", { silent = true, noremap = true }) |
| 1225 | map(0, "x", "gx", ":<c-u>Lspsaga range_code_action<cr>", {silent = true, noremap = true}) | 1434 | map(0, "x", "gx", ":<c-u>Lspsaga range_code_action<cr>", { silent = true, noremap = true }) |
| 1226 | map(0, "n", "K", "<cmd>Lspsaga hover_doc<cr>", {silent = true, noremap = true}) | 1435 | map(0, "n", "K", "<cmd>Lspsaga hover_doc<cr>", { silent = true, noremap = true }) |
| 1227 | map(0, "n", "go", "<cmd>Lspsaga show_line_diagnostics<cr>", {silent = true, noremap = true}) | 1436 | map(0, "n", "go", "<cmd>Lspsaga show_line_diagnostics<cr>", { silent = true, noremap = true }) |
| 1228 | map(0, "n", "gj", "<cmd>Lspsaga diagnostic_jump_next<cr>", {silent = true, noremap = true}) | 1437 | map(0, "n", "gj", "<cmd>Lspsaga diagnostic_jump_next<cr>", { silent = true, noremap = true }) |
| 1229 | map(0, "n", "gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>", {silent = true, noremap = true}) | 1438 | map(0, "n", "gk", "<cmd>Lspsaga diagnostic_jump_prev<cr>", { silent = true, noremap = true }) |
| 1230 | 1439 | ||
| 1231 | -- Don't know why... Everytime when modeline is set and insert a single char | 1440 | -- Don't know why... Everytime when modeline is set and insert a single char |
| 1232 | -- while inside a fold, the fold closes. | 1441 | -- while inside a fold, the fold closes. |
| 1233 | vim.opt_local.modeline = false | 1442 | vim.opt_local.modeline = false |
| 1234 | end, | 1443 | end, |
| 1235 | }) | 1444 | }) |
| 1236 | end | 1445 | end |
| 1237 | }, | 1446 | }, |
| 1238 | -- }}} | 1447 | -- }}} |
| 1239 | -- -- conform {{{ | 1448 | -- -- conform {{{ |