diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 742682f..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,32 +0,0 @@ -{ - "Comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" }, - "LuaSnip": { "branch": "master", "commit": "80a8528f084a97b624ae443a6f50ff8074ba486b" }, - "cmp-async-path": { "branch": "main", "commit": "d8229a93d7b71f22c66ca35ac9e6c6cd850ec61d" }, - "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, - "cmp-cmdline": { "branch": "main", "commit": "8ee981b4a91f536f52add291594e89fb6645e451" }, - "cmp-git": { "branch": "main", "commit": "f900a4cf117300fdc3ba31d26f8b6223ccd9c574" }, - "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f0f53f704c08ea501f9d222b23491b0d354644b0" }, - "cmp-treesitter": { "branch": "master", "commit": "b8bc760dfcc624edd5454f0982b63786a822eed9" }, - "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, - "gruvbox.nvim": { "branch": "main", "commit": "477c62493c82684ed510c4f70eaf83802e398898" }, - "lazy.nvim": { "branch": "main", "commit": "16603c6917435d8446f7357cb61095138a417085" }, - "lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" }, - "mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" }, - "mason.nvim": { "branch": "main", "commit": "cd7835b15f5a4204fc37e0aa739347472121a54c" }, - "null-ls.nvim": { "branch": "main", "commit": "0010ea927ab7c09ef0ce9bf28c2b573fc302f5a7" }, - "nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" }, - "nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" }, - "nvim-lspconfig": { "branch": "master", "commit": "d0467b9574b48429debf83f8248d8cee79562586" }, - "nvim-treesitter": { "branch": "master", "commit": "a8c14d68b024ffc20baec92d1acc91796bcfb485" }, - "nvim-treesitter-context": { "branch": "master", "commit": "2806d83e3965017382ce08792ee527e708fa1bd4" }, - "nvim-ts-rainbow2": { "branch": "master", "commit": "b3120cd5ae9ca524af9cb602f41e12e301fa985f" }, - "nvim-web-devicons": { "branch": "master", "commit": "5de460ca7595806044eced31e3c36c159a493857" }, - "plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" }, - "range-highlight.nvim": { "branch": "master", "commit": "8b5e8ccb3460b2c3675f4639b9f54e64eaab36d9" }, - "tagbar": { "branch": "master", "commit": "5d6990e4fc5b3e3b88a3af90146f2561c4f6d828" }, - "telescope.nvim": { "branch": "master", "commit": "4522d7e3ea75ffddabdc39957168a8a7060b5df0" }, - "vim-matchup": { "branch": "master", "commit": "6dbe108230c7dbbf00555b7d4d9f6a891837ef07" }, - "vim-sandwich": { "branch": "master", "commit": "c5a2cc438ce6ea2005c556dc833732aa53cae21a" } -} \ No newline at end of file diff --git a/lua/lazy-plugins.lua b/lua/lazy-plugins.lua index 63a1488..be9f92b 100644 --- a/lua/lazy-plugins.lua +++ b/lua/lazy-plugins.lua @@ -10,12 +10,14 @@ if not vim.loop.fs_stat(lazypath) then }) end vim.opt.rtp:prepend(lazypath) -opts = { + +local opts = { install = { colorscheme = { "gruvbox" } } } -require("lazy").setup({ + +local plugins = { { "ellisonleao/gruvbox.nvim", lazy = false, @@ -109,7 +111,13 @@ require("lazy").setup({ } }, "machakann/vim-sandwich", - "numToStr/Comment.nvim", + { + "numToStr/Comment.nvim", + event = "BufEnter", + config = function () + require("Comment").setup() + end + }, "andymass/vim-matchup", { "nvim-telescope/telescope.nvim", @@ -126,4 +134,23 @@ require("lazy").setup({ "winston0410/range-highlight.nvim", event = "CmdlineEnter" } -}, opts) +} + +local vscode_plugins = { + "machakann/vim-sandwich", + { + "numToStr/Comment.nvim", + event = "BufEnter", + config = function () + require("Comment").setup() + end + }, +} + +if vim.g.vscode then + -- VSCode extension + require("lazy").setup(vscode_plugins, opts) +else + -- ordinary Neovim + require("lazy").setup(plugins, opts) +end diff --git a/lua/mappings.lua b/lua/mappings.lua index a88f1b1..17c0b7a 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -2,10 +2,10 @@ local map = vim.api.nvim_set_keymap -- vscode if vim.g.vscode then - -- undo/REDO via vscode - map("n","u","call VSCodeNotify('undo')", {}) - map("n","","call VSCodeNotify('redo')", {}) - map("n","gf", "call VSCodeCall('editor.action.openLink')", {silent = true, noremap = true}) + -- undo/REDO via vscode + map("n", "u", "call VSCodeNotify('undo')", {}) + map("n", "", "call VSCodeNotify('redo')", {}) + map("n", "gf", "call VSCodeCall('editor.action.openLink')", { silent = true, noremap = true }) end -- generic mappings @@ -39,22 +39,9 @@ map('i', '?', '?u', { noremap = true }) -- plugin mappings -- gitsigns map('', 'gs', ':Gitsigns toggle_signs', { silent = true }) --- lsp stuff -map('n', 'gd', 'lua vim.lsp.buf.definition()', - { silent = false, noremap = true }) -map('n', 'K', 'lua vim.lsp.buf.hover()', { noremap = true }) -map('', 'K', 'lua vim.diagnostic.open_float()', - { noremap = true }) -map('', 'qf', - 'lua vim.diagnostic.setqflist({open = false})Telescope quickfix', - { silent = true }) - -- toggle tagbar map('', 'tt', ':TagbarToggle', { silent = true }) --- toggle formatter -map('', 'fm', ':lua vim.lsp.buf.format({async = true})', { silent = true }) - -- toggle Hop map('', 'b', ':HopWordBC', { silent = true }) map('', 'w', ':HopWordAC', { silent = true }) diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 93511e4..17b54a3 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,15 +1,52 @@ -require("mason").setup {ui = {icons = {package_installed = "✓"}}} +-- Global mappings. +-- See `:help vim.diagnostic.*` for documentation on any of the below functions +vim.keymap.set('n', 'e', vim.diagnostic.open_float) +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist) + +-- Use LspAttach autocommand to only map the following keys +-- after the language server attaches to the current buffer +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + -- Enable completion triggered by + vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc' + + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf } + vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts) + vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) + vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts) + vim.keymap.set('n', '', vim.lsp.buf.signature_help, opts) + vim.keymap.set('n', 'wa', vim.lsp.buf.add_workspace_folder, opts) + vim.keymap.set('n', 'wr', vim.lsp.buf.remove_workspace_folder, opts) + vim.keymap.set('n', 'wl', function() + print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + end, opts) + vim.keymap.set('n', 'D', vim.lsp.buf.type_definition, opts) + vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) + vim.keymap.set({ 'n', 'v' }, 'ca', vim.lsp.buf.code_action, opts) + vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts) + vim.keymap.set('n', 'f', function() + vim.lsp.buf.format { async = true } + end, opts) + end, +}) + +require("mason").setup { ui = { icons = { package_installed = "✓" } } } require("mason-lspconfig").setup {} -- Dynamic loading of lsp servers require("mason-lspconfig").setup_handlers { - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn't have - -- a dedicated handler. - function(server_name) -- default handler (optional) - require("lspconfig")[server_name].setup {} - end, - -- Next, you can provide targeted overrides for specific servers. - -- For example, a handler override for the `rust_analyzer`: - ["rust_analyzer"] = function() require("rust-tools").setup {} end + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function(server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, + -- Next, you can provide targeted overrides for specific servers. + -- For example, a handler override for the `rust_analyzer`: + ["rust_analyzer"] = function() require("rust-tools").setup {} end } -