diff --git a/README.md b/README.md index 9d97920..0fc0eb3 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ There are some packages required by Mason, Telescope, etc. -**Note: this list is very loose list.** +**Note: this is a very loose list.** ```shell sudo apt install gcc ripgrep unzip java-common default-jre luarocks cmake libbinutils moreutils shellcheck @@ -15,7 +15,8 @@ sudo apt install gcc ripgrep unzip java-common default-jre luarocks cmake libbin ``` :MasonInstall lua-language-server@3.15.0 :MasonInstall typescript-language-server -:MasonInstall rust_analyzer +:MasonInstall vue-language-server +:MasonInstall rust-analyzer ``` ## NerdFont diff --git a/init.lua b/init.lua index 260588f..872946f 100644 --- a/init.lua +++ b/init.lua @@ -4,22 +4,22 @@ require 'spec' spec 'plugin/colorscheme' spec 'plugin/treesitter' spec 'plugin/telescope' +spec 'plugin/telescope-ui-select' spec 'plugin/mason' spec 'plugin/nvimtree' spec 'plugin/nvimtree-icons' spec 'plugin/toggleterm' spec 'plugin/lspconfig' --- spec 'plugin/bufferline' --- spec 'plugin/copilot' --- spec 'plugin/smartword' --- spec 'plugin/gitsigns' --- spec 'plugin/lualine' +spec 'plugin/bufferline' +spec 'plugin/copilot' +spec 'plugin/smartword' +spec 'plugin/gitsigns' +spec 'plugin/lualine' spec 'plugin/autopairs' spec 'plugin/lspkind' spec 'plugin/nvim-cmp' --- spec 'plugin/nvim-navic' --- spec 'plugin/csvview' --- spec 'plugin/which-key' +spec 'plugin/which-key' +spec 'plugin/todo-comments' require 'plugin/lazy' require 'lsp' diff --git a/lazy-lock.json b/lazy-lock.json index e373385..3eb781b 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,20 +1,28 @@ { + "bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" }, "cmp-path": { "branch": "main", "commit": "c642487086dbd9a93160e1679a1327be111cbc25" }, + "copilot.vim": { "branch": "release", "commit": "a12fd5672110c8aa7e3c8419e28c96943ca179be" }, + "gitsigns.nvim": { "branch": "main", "commit": "abf82a65f185bd54adc0679f74b7d6e1ada690c9" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "lspkind.nvim": { "branch": "master", "commit": "3ddd1b4edefa425fda5a9f95a4f25578727c0bb3" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "4cfe411526a7a99c18281135e8b4765ae6330d15" }, - "mason.nvim": { "branch": "main", "commit": "57e5a8addb8c71fb063ee4acda466c7cf6ad2800" }, + "lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "fe661093f4b05136437b531e7f959af2a2ae66c8" }, + "mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" }, "nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" }, - "nvim-cmp": { "branch": "main", "commit": "d97d85e01339f01b842e6ec1502f639b080cb0fc" }, - "nvim-lspconfig": { "branch": "master", "commit": "41ceb6bba3a40128b7841f5b7f5a9dae7201e823" }, + "nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" }, + "nvim-lspconfig": { "branch": "master", "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" }, "nvim-tree.lua": { "branch": "master", "commit": "b8b44b6a2494d086a9177251a119f9daec6cace8" }, - "nvim-treesitter": { "branch": "main", "commit": "7efc1b58a8061d29786860006c7257c90a5196dc" }, + "nvim-treesitter": { "branch": "main", "commit": "5a7e5638e7d220575b1c22c8a2e099b52231886e" }, "nvim-web-devicons": { "branch": "master", "commit": "6788013bb9cb784e606ada44206b0e755e4323d7" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, - "telescope.nvim": { "branch": "master", "commit": "4d0f5e0e7f69071e315515c385fab2a4eff07b3d" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "3333a52ff548ba0a68af6d8da1e54f9cd96e9179" }, + "todo-comments.nvim": { "branch": "main", "commit": "31e3c38ce9b29781e4422fc0322eb0a21f4e8668" }, "toggleterm.nvim": { "branch": "main", "commit": "9a88eae817ef395952e08650b3283726786fb5fb" }, - "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" } + "tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }, + "vim-smartword": { "branch": "master", "commit": "608d4883bb1eff4131f44857a21119220e55886d" }, + "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" } } diff --git a/lsp/lua_ls.lua b/lsp/lua_ls.lua index 232c5ce..92f3ce7 100644 --- a/lsp/lua_ls.lua +++ b/lsp/lua_ls.lua @@ -9,8 +9,8 @@ return { globals = { 'vim' }, }, workspace = { - library = vim.api.nvim_get_runtime_file('', true), - checkThirdParty = true, + library = vim.tbl_deep_extend('force', vim.api.nvim_get_runtime_file('', true), { '${3rd}/love2d/library' }), + checkThirdParty = false, }, }, }, diff --git a/lua/general.lua b/lua/general.lua index 915620c..f4208b8 100644 --- a/lua/general.lua +++ b/lua/general.lua @@ -28,7 +28,12 @@ vim.opt.listchars = { tab = ' - ', } -vim.opt.signcolumn = 'number' +vim.opt.signcolumn = 'yes' vim.opt.scrolloff = 10 -vim.diagnostic.config { virtual_text = true } +vim.diagnostic.config { + virtual_text = true, + jump = { float = true } +} + +vim.opt.winborder = 'single' diff --git a/lua/keymap.lua b/lua/keymap.lua index afd1883..e9eab22 100644 --- a/lua/keymap.lua +++ b/lua/keymap.lua @@ -3,78 +3,75 @@ local horizontal_resize_step = 8 local small_step = 5 local big_step = 25 -vim.keymap.set('n', 'w', 'w') -vim.keymap.set('n', 'q', 'q') -vim.keymap.set('n', 'c', 'bpbd#') -vim.keymap.set('n', 'h', 'nohl') -vim.keymap.set('n', 'z', 'set wrap! wrap?') -vim.keymap.set('n', 'x', 'set cursorline! cursorline?') +vim.keymap.set('n', 'w', 'w', { desc = 'Write buffer' }) +vim.keymap.set('n', 'q', 'q', { desc = 'Close window' }) +vim.keymap.set('n', 'c', 'bpbd#', { desc = 'Close buffer' }) +vim.keymap.set('n', 'h', 'nohl', { desc = 'Clear highlight' }) +vim.keymap.set('n', 'z', 'set wrap! wrap?', { desc = 'Toggle wrap' }) +vim.keymap.set('n', 'x', 'set cursorline! cursorline?', { desc = 'Toggle cursorline' }) -vim.keymap.set('n', '', 'k') -vim.keymap.set('n', '', 'j') -vim.keymap.set('n', '', 'h') -vim.keymap.set('n', '', 'l') -vim.keymap.set('n', '', 'k') -vim.keymap.set('n', '', 'j') -vim.keymap.set('n', '', 'h') -vim.keymap.set('n', '', 'l') +vim.keymap.set('n', '', 'k', { desc = 'Move to upper window' }) +vim.keymap.set('n', '', 'j', { desc = 'Move to lower window' }) +vim.keymap.set('n', '', 'h', { desc = 'Move to left window' }) +vim.keymap.set('n', '', 'l', { desc = 'Move to right window' }) -vim.keymap.set('n', '', 'resize +' .. vertical_resize_step .. '') -vim.keymap.set('n', '', 'resize -' .. vertical_resize_step .. '') -vim.keymap.set('n', '', 'vertical resize -' .. horizontal_resize_step .. '') -vim.keymap.set('n', '', 'vertical resize +' .. horizontal_resize_step .. '') +vim.keymap.set('n', '', 'resize +' .. vertical_resize_step .. '', { desc = 'Increase window height' }) +vim.keymap.set('n', '', 'resize -' .. vertical_resize_step .. '', { desc = 'Decrease window height' }) +vim.keymap.set('n', '', 'vertical resize -' .. horizontal_resize_step .. '', { desc = 'Decrease window width' }) +vim.keymap.set('n', '', 'vertical resize +' .. horizontal_resize_step .. '', { desc = 'Increase window width' }) -vim.keymap.set({'n', 'v'}, '', small_step .. 'k') -vim.keymap.set({'n', 'v'}, '', small_step .. 'j') -vim.keymap.set({'n', 'v'}, '', small_step .. '' .. small_step .. 'k') -vim.keymap.set({'n', 'v'}, '', small_step .. '' .. small_step .. 'j') -vim.keymap.set({'n', 'v'}, '', big_step .. 'lua center_cursor()') -vim.keymap.set({'n', 'v'}, '', big_step .. 'lua center_cursor()') -vim.keymap.set({'n', 'v'}, '', '^') -vim.keymap.set({'n', 'v'}, '', '$') -vim.keymap.set('n', 'zz', center_cursor) -vim.keymap.set('i', '', '' .. small_step .. 'k') -vim.keymap.set('i', '', '' .. small_step .. 'j') -vim.keymap.set('i', '', '' .. small_step .. '' .. small_step .. 'k') -vim.keymap.set('i', '', '' .. small_step .. '' .. small_step .. 'j') -vim.keymap.set('i', '', '' .. big_step .. 'lua center_cursor()') -vim.keymap.set('i', '', '' .. big_step .. 'lua center_cursor()') -vim.keymap.set('i', '', '^') -vim.keymap.set('i', '', '$') +vim.keymap.set({'n', 'v'}, '', small_step .. 'k', { desc = 'Move cursor up ' .. small_step .. ' lines' }) +vim.keymap.set({'n', 'v'}, '', small_step .. 'j', { desc = 'Move cursor down ' .. small_step .. ' lines' }) +vim.keymap.set({'n', 'v'}, '', small_step .. '' .. small_step .. 'k', { desc = 'Scroll up ' .. small_step .. ' lines' }) +vim.keymap.set({'n', 'v'}, '', small_step .. '' .. small_step .. 'j', { desc = 'Scroll down ' .. small_step .. ' lines' }) +vim.keymap.set({'n', 'v'}, '', big_step .. 'lua center_cursor()', { desc = 'Page up' }) +vim.keymap.set({'n', 'v'}, '', big_step .. 'lua center_cursor()', { desc = 'Page down' }) +vim.keymap.set({'n', 'v'}, '', '^', { desc = 'Move to beginning of line' }) +vim.keymap.set({'n', 'v'}, '', '$', { desc = 'Move to end of line' }) +vim.keymap.set('n', 'zz', center_cursor, { desc = 'Center cursor vertically' }) +vim.keymap.set('i', '', '' .. small_step .. 'k', { desc = 'Move cursor up ' .. small_step .. ' lines' }) +vim.keymap.set('i', '', '' .. small_step .. 'j', { desc = 'Move cursor down ' .. small_step .. ' lines' }) +vim.keymap.set('i', '', '' .. small_step .. '' .. small_step .. 'k', { desc = 'Scroll up ' .. small_step .. ' lines' }) +vim.keymap.set('i', '', '' .. small_step .. '' .. small_step .. 'j', { desc = 'Scroll down ' .. small_step .. ' lines' }) +vim.keymap.set('i', '', '' .. big_step .. 'lua center_cursor()', { desc = 'Page up' }) +vim.keymap.set('i', '', '' .. big_step .. 'lua center_cursor()', { desc = 'Page down' }) +vim.keymap.set('i', '', '^', { desc = 'Move to beginning of line' }) +vim.keymap.set('i', '', '$', { desc = 'Move to end of line' }) -vim.keymap.set('i', '', '') -vim.keymap.set('i', '', '"_dw') +-- is interpreted as (^H) by my terminal. You can check yours with in insert mode. +vim.keymap.set('i', '', '', { desc = 'Remove word backwards' }) +vim.keymap.set('i', '', '"_dw', { desc = 'Remove word forwards' }) -vim.keymap.set('n', '', '"_dd') -vim.keymap.set('v', '', '"_d') -vim.keymap.set('n', '', 'mzk"_ddg`z') +vim.keymap.set('n', '', '"_dd', { desc = 'Delete line without yanking' }) +vim.keymap.set('v', '', '"_d', { desc = 'Delete selection without yanking' }) +vim.keymap.set('n', '', 'mzk"_ddg`z', { desc = 'Delete line above without yanking' }) -vim.keymap.set('n', '', 'call append(line("."), "")') -vim.keymap.set('i', '', 'O') +vim.keymap.set('n', '', 'call append(line("."), "")', { desc = 'Insert newline below' }) +vim.keymap.set('i', '', '$', { desc = 'Insert newline below and go to it' }) -vim.keymap.set({'n', 'i'}, '', 'm -2') -vim.keymap.set({'n', 'i'}, '', 'm +1') +vim.keymap.set({'n', 'i'}, '', 'm -2', { desc = 'Move line up' }) +vim.keymap.set({'n', 'i'}, '', 'm +1', { desc = 'Move line down' }) vim.cmd [[ xnoremap :m-2gv=gv xnoremap :m'>+gv=gv ]] -vim.keymap.set('v', '>', '>gv') -vim.keymap.set('v', '<', '', '>gv', { desc = 'Indent selection right' }) +vim.keymap.set('v', '<', '') +vim.keymap.set('n', 'gd', '', { desc = 'Jump to definition' }) -vim.keymap.set('n', '/', 'gcc', { remap = true }) -vim.keymap.set('v', '/', 'gcgv', { remap = true }) +vim.keymap.set('n', '/', 'gcc', { remap = true, desc = 'Toggle comment' }) +vim.keymap.set('v', '/', 'gcgv', { remap = true, desc = 'Toggle comment' }) -vim.keymap.set('n', 'gl', 'lua vim.diagnostic.open_float()') -vim.keymap.set('n', 'gj', 'lua vim.diagnostic.goto_next()') -vim.keymap.set('n', 'gk', 'lua vim.diagnostic.goto_prev()') +vim.keymap.set('n', 'gl', vim.diagnostic.open_float, { desc = 'Show diagnostics' }) +vim.keymap.set('n', 'gj', function() vim.diagnostic.jump { count = 1 } end, { desc = 'Next diagnostic' }) +vim.keymap.set('n', 'gk', function() vim.diagnostic.jump { count = -1 } end, { desc = 'Previuous diagnostic' }) -vim.keymap.set('n', 'la', 'gra') -vim.keymap.set('n', 'lf', 'lua vim.lsp.buf.format({ async = true })') -vim.keymap.set('n', 'ln', 'lua vim.lsp.buf.rename()') -vim.keymap.set('n', 'lr', 'lua vim.lsp.buf.references()') +vim.keymap.set('n', 'la', vim.lsp.buf.code_action, { desc = 'Code actions' }) +vim.keymap.set('n', 'lf', function() vim.lsp.buf.format { async = true } end, { desc = 'Format buffer' }) +vim.keymap.set('n', 'ln', vim.lsp.buf.rename, { desc = 'Rename symbol' }) +vim.keymap.set('n', 'lr', vim.lsp.buf.references, { desc = 'List references' }) for _, keymap in pairs(PLUGIN_KEYMAPS) do keymap() diff --git a/lua/plugin/bufferline.lua b/lua/plugin/bufferline.lua new file mode 100644 index 0000000..b75df63 --- /dev/null +++ b/lua/plugin/bufferline.lua @@ -0,0 +1,39 @@ +local M = { + 'akinsho/bufferline.nvim', + dependencies = 'nvim-tree/nvim-web-devicons', +} + +M.config = function() + vim.opt.termguicolors = true + + require 'bufferline'.setup { + options = { + offsets = { + { + filetype = 'NvimTree', + text = 'File Explorer 󰄛', + highlight = 'Directory', + padding = 1, + separator = false, + }, + }, + diagnostics = 'nvim_lsp', + show_buffer_close_icons = false, + show_close_icon = false, + indicator = { + style = 'icon', + icon = '▎', + }, + modified_icon = '', + }, + } +end + +M.keymap = function() + vim.keymap.set('n', '', 'BufferLineCyclePrev', { desc = 'Previous buffer' }) + vim.keymap.set('n', '', 'BufferLineCycleNext', { desc = 'Next buffer' }) + vim.keymap.set('n', '', 'BufferLineCyclePrev', { desc = 'Previous buffer' }) + vim.keymap.set('n', '', 'BufferLineCycleNext', { desc = 'Next buffer' }) +end + +return M diff --git a/lua/plugin/copilot.lua b/lua/plugin/copilot.lua new file mode 100644 index 0000000..6ee4240 --- /dev/null +++ b/lua/plugin/copilot.lua @@ -0,0 +1,36 @@ +local M = { + 'github/copilot.vim', +} + +local copilot_enabled = true + +M.keymap = function() + vim.g.copilot_no_tab_map = true + vim.keymap.set('i', '', 'copilot#Accept("\\")', { + expr = true, + replace_keycodes = false, + desc = 'Accept Copilot suggestion' + }) + vim.keymap.set('i', '', 'copilot#Accept("\\")', { + expr = true, + replace_keycodes = false, + desc = 'Accept Copilot suggestion' + }) + vim.keymap.set('i', '', 'copilot#AcceptWord("\\")', { + expr = true, + replace_keycodes = false, + desc = 'Accept Copilot suggested word' + }) + vim.keymap.set('n', 'd', function() + if copilot_enabled then + vim.cmd.Copilot('disable') + vim.notify('Copilot off', vim.log.levels.INFO) + else + vim.cmd.Copilot('enable') + vim.notify('Copilot on', vim.log.levels.INFO) + end + copilot_enabled = not copilot_enabled + end, { desc = 'Toggle Copilot' }) +end + +return M diff --git a/lua/plugin/gitsigns.lua b/lua/plugin/gitsigns.lua new file mode 100644 index 0000000..29ce544 --- /dev/null +++ b/lua/plugin/gitsigns.lua @@ -0,0 +1,43 @@ +local M = { + 'lewis6991/gitsigns.nvim', + opts = { + signs = { + add = { text = '█' }, + change = { text = '█' }, + delete = { text = '█' }, + topdelete = { text = '█' }, + changedelete = { text = '█' }, + untracked = { text = '?' }, + }, + signs_staged = { + add = { text = '▌' }, + change = { text = '▌' }, + delete = { text = '▌' }, + topdelete = { text = '▌' }, + changedelete = { text = '▌' }, + untracked = { text = '?' }, + }, + signs_staged_enable = true, + current_line_blame = true, + max_file_length = 40000, + }, +} + +M.keymap = function() + local git = require 'gitsigns' + + vim.keymap.set('n', 'gl', git.blame_line, { desc = 'Git blame line' }) + vim.keymap.set('n', 'gg', git.toggle_word_diff, { desc = 'Git toggle word diff' }) + vim.keymap.set({ 'n', 'v' }, 'gr', git.reset_hunk, { desc = 'Git reset hunk' }) + vim.keymap.set('n', '', git.stage_buffer, { desc = 'Git stage buffer' }) + vim.keymap.set('n', '', function() git.nav_hunk 'next' end, { desc = 'Git next hunk' }) + vim.keymap.set('n', '', function() git.nav_hunk 'prev' end, { desc = 'Git previous hunk' }) + vim.keymap.set('n', '', function() git.nav_hunk 'next' end, { desc = 'Git next hunk' }) + vim.keymap.set('n', '', function() git.nav_hunk 'prev' end, { desc = 'Git previous hunk' }) + vim.keymap.set('n', '', git.preview_hunk, { desc = 'Git preview hunk' }) + vim.keymap.set('n', '', git.stage_hunk, { desc = 'Git stage hunk' }) + vim.keymap.set('n', '', git.preview_hunk, { desc = 'Git preview hunk' }) + vim.keymap.set('n', '', git.stage_hunk, { desc = 'Git stage hunk' }) +end + +return M diff --git a/lua/plugin/lazy.lua b/lua/plugin/lazy.lua index e457b49..4f70000 100644 --- a/lua/plugin/lazy.lua +++ b/lua/plugin/lazy.lua @@ -1,5 +1,5 @@ local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' -if not vim.loop.fs_stat(lazypath) then +if not vim.uv.fs_stat(lazypath) then vim.fn.system { 'git', 'clone', diff --git a/lua/plugin/lualine.lua b/lua/plugin/lualine.lua new file mode 100644 index 0000000..bf3414b --- /dev/null +++ b/lua/plugin/lualine.lua @@ -0,0 +1,12 @@ +local M = { + 'nvim-lualine/lualine.nvim', + dependencies = { 'nvim-tree/nvim-web-devicons' }, + opts = { + options = { + section_separators = { left = '▒', right = '▒' }, + component_separators = { left = '', right = '' }, + }, + }, +} + +return M diff --git a/lua/plugin/mason.lua b/lua/plugin/mason.lua index d85c80a..9e6e091 100644 --- a/lua/plugin/mason.lua +++ b/lua/plugin/mason.lua @@ -3,9 +3,9 @@ local M = { opts = { ui = { icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗" + package_installed = '✓', + package_pending = '➜', + package_uninstalled = '✗' }, }, }, diff --git a/lua/plugin/nvim-cmp.lua b/lua/plugin/nvim-cmp.lua index 64f971e..efdcfb8 100644 --- a/lua/plugin/nvim-cmp.lua +++ b/lua/plugin/nvim-cmp.lua @@ -34,26 +34,25 @@ M.config = function() local kind = require 'lspkind'.cmp_format { mode = 'symbol_text', maxwidth = 50, - }(entry, vim_item) + } (entry, vim_item) local strings = vim.split(kind.kind, '%s', { trimempty = true }) kind.kind = ' ' .. (strings[1] or '') .. ' ' kind.menu = ' (' .. (strings[2] or '') .. ')' return kind end }, - mapping = cmp.mapping.preset.insert({ + -- mapping = cmp.mapping.preset.insert { + mapping = { [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete(), + [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), [''] = cmp.mapping.select_next_item(), [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - }), + [''] = cmp.mapping.confirm { select = true }, -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }, sources = cmp.config.sources( { { name = 'nvim_lsp' }, @@ -74,4 +73,17 @@ M.config = function() ) end +M.keymap = function() + local cmp = require 'cmp' + vim.keymap.set('n', 'a', function() + if cmp.get_config().completion.autocomplete then + cmp.setup { completion = { autocomplete = false } } + vim.notify('Autocomplete off', vim.log.levels.INFO) + else + cmp.setup { completion = { autocomplete = { cmp.TriggerEvent.TextChanged } } } + vim.notify('Autocomplete on', vim.log.levels.INFO) + end + end, { desc = 'Toggle autocomplete' }) +end + return M diff --git a/lua/plugin/nvimtree.lua b/lua/plugin/nvimtree.lua index 629093f..ad3c151 100644 --- a/lua/plugin/nvimtree.lua +++ b/lua/plugin/nvimtree.lua @@ -9,10 +9,52 @@ local M = { side = 'left', width = 40, }, + renderer = { + indent_width = 2, + highlight_git = true, + highlight_opened_files = 'all', + icons = { + git_placement = 'right_align', + show = { + git = true, + folder = true, + file = true, + folder_arrow = true, + }, + glyphs = { + git = { + unstaged = '~', + staged = '✓', + unmerged = '', + renamed = '󱦰', + untracked = '?', + deleted = '', + ignored = '', + }, + }, + } + }, + filters = { + enable = true, + git_ignored = false, + dotfiles = false, + git_clean = false, + no_buffer = false, + no_bookmark = false, + }, + live_filter = { + always_show_folders = false, + }, actions = { expand_all = { - max_folder_discovery = 1000, - exclude = { '.git', 'target', 'build', 'node_modules' }, + max_folder_discovery = 3000, + exclude = { + '.git', + 'target', + 'build', + 'node_modules', + '.yarn', + }, }, }, update_focused_file = { @@ -21,13 +63,13 @@ local M = { diagnostics = { enable = true, show_on_dirs = true, - show_on_open_dirs = true, + show_on_open_dirs = false, }, }, } M.keymap = function() - vim.keymap.set('n', 'e', 'NvimTreeFindFileToggle') + vim.keymap.set('n', 'e', 'NvimTreeFindFileToggle', { desc = 'Toggle Nvim Tree' }) end return M diff --git a/lua/plugin/smartword.lua b/lua/plugin/smartword.lua new file mode 100644 index 0000000..a3cd29e --- /dev/null +++ b/lua/plugin/smartword.lua @@ -0,0 +1,12 @@ +local M = { + 'kana/vim-smartword', +} + +M.config = function() + vim.keymap.set({ 'n', 'v' }, '', '(smartword-e)') + vim.keymap.set({ 'n', 'v' }, '', '(smartword-b)') + vim.keymap.set('i', '', '(smartword-e)a') + vim.keymap.set('i', '', '(smartword-b)') +end + +return M diff --git a/lua/plugin/telescope-ui-select.lua b/lua/plugin/telescope-ui-select.lua new file mode 100644 index 0000000..8e4e9fa --- /dev/null +++ b/lua/plugin/telescope-ui-select.lua @@ -0,0 +1,6 @@ +local M = { + 'nvim-telescope/telescope-ui-select.nvim', + dependencies = { 'nvim-telescope/telescope.nvim' }, +} + +return M diff --git a/lua/plugin/telescope.lua b/lua/plugin/telescope.lua index 307a314..337f2af 100644 --- a/lua/plugin/telescope.lua +++ b/lua/plugin/telescope.lua @@ -6,6 +6,7 @@ local M = { } function M.config() + local telescope = require 'telescope' local actions = require 'telescope.actions' require 'telescope'.setup { defaults = { @@ -23,7 +24,6 @@ function M.config() sorting_strategy = 'ascending', scroll_strategy = 'limit', mappings = { - i = {}, n = { [''] = actions.close, ['q'] = actions.close, @@ -44,31 +44,37 @@ function M.config() extensions = { file_browser = { git_icons = { - added = "A", - changed = "M", - copied = "C", - deleted = "D", - renamed = "R", - unmerged = "U", - untracked = "?", + added = 'A', + changed = 'M', + copied = 'C', + deleted = 'D', + renamed = 'R', + unmerged = 'U', + untracked = '?', }, }, }, } + telescope.load_extension 'ui-select' end M.keymap = function() local builtin = require 'telescope.builtin' - vim.keymap.set('n', 'f', builtin.find_files) - vim.keymap.set('n', 'r', builtin.resume) - vim.keymap.set('n', '', function() builtin.grep_string { word_match = '-w' } end) - vim.keymap.set('v', '', builtin.grep_string) - vim.keymap.set('n', 'st', builtin.live_grep) - vim.keymap.set('n', 'o', builtin.lsp_document_symbols) - vim.keymap.set('n', 'p', builtin.lsp_workspace_symbols) - vim.keymap.set('n', 'gb', builtin.git_branches) - vim.keymap.set('n', 'gc', builtin.git_commits) - vim.keymap.set('n', '', builtin.git_status) + vim.keymap.set('n', 'f', builtin.find_files, { desc = 'Find files' }) + vim.keymap.set('n', 'r', builtin.resume, { desc = 'Resume last search' }) + vim.keymap.set('n', '', function() builtin.grep_string { word_match = '-w' } end, + { desc = 'Find word under cursor' }) + vim.keymap.set('v', '', builtin.grep_string, { desc = 'Find visual selection' }) + vim.keymap.set('n', 'st', builtin.live_grep, { desc = 'Search for text in files' }) + vim.keymap.set('n', 'sd', builtin.diagnostics, { desc = 'List diagnostics' }) + vim.keymap.set('n', 'o', builtin.lsp_document_symbols, { desc = 'List document symbols' }) + vim.keymap.set('n', 'p', builtin.lsp_workspace_symbols, { desc = 'List workspace symbols' }) + vim.keymap.set('n', 'gb', builtin.git_branches, { desc = 'List git branches' }) + vim.keymap.set('n', 'gc', builtin.git_commits, { desc = 'List git commits' }) + vim.keymap.set('n', '', function() builtin.git_status { + max_results = 10000, + temp__scrolling_limit = 10000, + } end, { desc = 'Git status' }) end return M diff --git a/lua/plugin/todo-comments.lua b/lua/plugin/todo-comments.lua new file mode 100644 index 0000000..08ddfc1 --- /dev/null +++ b/lua/plugin/todo-comments.lua @@ -0,0 +1,11 @@ +local M = { + 'folke/todo-comments.nvim', + dependencies = { 'nvim-lua/plenary.nvim' }, + opts = {}, +} + +M.keymap = function() + vim.keymap.set('n', 't', 'TodoTelescope', { desc = 'Find TODO comments' }) +end + +return M diff --git a/lua/plugin/toggleterm.lua b/lua/plugin/toggleterm.lua index f1c3052..948ed7e 100644 --- a/lua/plugin/toggleterm.lua +++ b/lua/plugin/toggleterm.lua @@ -5,7 +5,7 @@ local M = { M.keymap = function() for i = 1, 9 do - vim.keymap.set({'n', 't'}, '', '' .. i .. 'ToggleTerm direction=float name=term-' .. i .. '') + vim.keymap.set({'n', 't'}, '', '' .. i .. 'ToggleTerm direction=float name=term-' .. i .. '', { desc = 'Toggle terminal ' .. i }) end end diff --git a/lua/plugin/which-key.lua b/lua/plugin/which-key.lua new file mode 100644 index 0000000..4923305 --- /dev/null +++ b/lua/plugin/which-key.lua @@ -0,0 +1,16 @@ +local M = { + 'folke/which-key.nvim', + event = 'VeryLazy', + config = true, + keys = { + { + '?', + function() + require 'which-key'.show({ global = false }) + end, + desc = 'Buffer local mappings', + } + } +} + +return M