diff options
| Commit | 7906ecc0e38ff6b1be54668e49ea10906b743bc1 (patch) | |
|---|---|---|
| Author | 2024-09-15 09:49:48 +0300 | |
| Committer | 2024-09-15 09:49:48 +0300 | |
| Files | 16019bad2864ce3126675df6ca7ef5bbdc5a59ce | |
| anderson-7906ecc0e38ff6b1be54668e49ea10906b743bc1.tar anderson-7906ecc0e38ff6b1be54668e49ea10906b743bc1.tar.gz anderson-7906ecc0e38ff6b1be54668e49ea10906b743bc1.zip | ||
| Parent | 707deef34a9fdafd276b3a237428ed4052468ff2 (diff) | |
feat(plugins): Properly implemented lsp
2 files changed, 105 insertions, 18 deletions
| -rw-r--r-- | lazy-lock.json | 21 | ||||
| -rw-r--r-- | lua/plugins/lsp.lua | 102 |
diff --git a/lazy-lock.json b/lazy-lock.json index a883af0..4385579 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,22 +1,27 @@ { "Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, "git-blame.vim": { "branch": "master", "commit": "9d144b7bed5d8f1c9259551768b7f3b3d1294917" }, "gruvbox": { "branch": "master", "commit": "f1ecde848f0cdba877acb0c740320568252cc482" }, "gruvbox-highlight.nvim": { "branch": "main", "commit": "00b2055a1b65d9d25d62411d0c2233cf6fe34329" }, "heirline.nvim": { "branch": "master", "commit": "0d797435e54645a5f98bad7ad6046aac1ef95c1e" }, - "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" }, + "lazy.nvim": { "branch": "main", "commit": "48b52b5cfcf8f88ed0aff8fde573a5cc20b1306d" }, + "lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" }, "lua-utils.nvim": { "branch": "main", "commit": "e565749421f4bbb5d2e85e37c3cef9d56553d8bd" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" }, + "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" }, "neorg": { "branch": "main", "commit": "ace80b05771b65d6633f3c64b8d930b5787f20d0" }, "nerdtree": { "branch": "master", "commit": "9b465acb2745beb988eff3c1e4aa75f349738230" }, - "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" }, - "nvim-lspconfig": { "branch": "master", "commit": "81a19de18990208b678be084597613e2dbe66912" }, + "nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" }, + "nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" }, + "nvim-lspconfig": { "branch": "master", "commit": "0d027de8820917db548486564d0d5b17af4b3db4" }, "nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" }, - "nvim-treesitter": { "branch": "master", "commit": "397982d197768ebdefc0e2db396d95c4d371ca86" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "41e3abf6bfd9a9a681eb1f788bdeba91c9004b2b" }, - "nvim-ts-autotag": { "branch": "main", "commit": "0cb76eea80e9c73b88880f0ca78fbd04c5bdcac7" }, - "nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" }, - "pathlib.nvim": { "branch": "main", "commit": "7a5a6facd29e306bc73a37719fa67c0d2226f852" }, + "nvim-treesitter": { "branch": "master", "commit": "399062d072355be7cd3441a7931cb05378a6c6a2" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "bf8d2ad35d1d1a687eae6c065c3d524f7ab61b23" }, + "nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" }, + "nvim-web-devicons": { "branch": "master", "commit": "9154484705968658e9aab2b894d1b2a64bf9f83d" }, + "pathlib.nvim": { "branch": "main", "commit": "57e5598af6fe253761c1b48e0b59b7cd6699e2c1" }, "plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" }, "tabular": { "branch": "master", "commit": "12437cd1b53488e24936ec4b091c9324cafee311" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" }, diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 8144527..d778448 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -9,8 +9,10 @@ vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { callback = functi end}) return { + -- Syntax parsing (for highlighting) { - "nvim-treesitter/nvim-treesitter", -- Advanced syntax parsing + "nvim-treesitter/nvim-treesitter", + lazy = false, build = ":TSUpdate", opts = { ensure_installed = "all", @@ -23,19 +25,99 @@ return { require("nvim-treesitter.configs").setup(opts) end, }, + -- LSP server utilisation { "neovim/nvim-lspconfig", - enabled = false, -- Figure out config property - event = "LazyFile", - -- dependencies = { - -- "mason.nvim", - -- { "williamboman/mason-lspconfig.nvim", config = function() end }, - -- }, + dependencies = { 'VonHeikemen/lsp-zero.nvim' }, + lazy = true, opts = { - servers = { - awk_ls = { settings = {}, }, + awk_ls = { }, + lua_ls = { }, + }, + config = function(_, opts) + for k,v in pairs(opts) do + require("lspconfig")[k].setup(v) + end + end, + }, + -- Auto-completion + { + 'hrsh7th/cmp-nvim-lsp', + config = true, + lazy = true + }, + { + 'hrsh7th/nvim-cmp', + lazy = false, + opts = { + sources = { { name = 'nvim_lsp' } }, + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + }, + config = function(_, opts) + local cmp = require('cmp') + opts.mapping = cmp.mapping.preset.insert({ + -- -- `Enter` key to confirm completion + -- ['<CR>'] = cmp.mapping.confirm({select = false}), + -- + -- -- Ctrl+Space to trigger completion menu + ['<C-Space>'] = cmp.mapping.complete(), + -- + -- -- Navigate between snippet placeholder + -- ['<C-f>'] = cmp_action.vim_snippet_jump_forward(), + -- ['<C-b>'] = cmp_action.vim_snippet_jump_backward(), + -- + -- -- Scroll up and down in the completion documentation + -- ['<C-u>'] = cmp.mapping.scroll_docs(-4), + -- ['<C-d>'] = cmp.mapping.scroll_docs(4), + }) + cmp.setup(opts) + end, + }, + -- Helper functions + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v3.x', + lazy = true, + dependencies = { 'hrsh7th/cmp-nvim-lsp' }, + opts = { + sign_text = true, + capabailities = "", + lsp_attach = function(client, bufnr) + local opts = {buffer = bufnr} + + vim.keymap.set('n', 'K', '<cmd>lua vim.lsp.buf.hover()<cr>', opts) + vim.keymap.set('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<cr>', opts) + vim.keymap.set('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<cr>', opts) + vim.keymap.set('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<cr>', opts) + vim.keymap.set('n', 'go', '<cmd>lua vim.lsp.buf.type_definition()<cr>', opts) + vim.keymap.set('n', 'gr', '<cmd>lua vim.lsp.buf.references()<cr>', opts) + vim.keymap.set('n', 'gs', '<cmd>lua vim.lsp.buf.signature_help()<cr>', opts) + vim.keymap.set('n', '<F2>', '<cmd>lua vim.lsp.buf.rename()<cr>', opts) + vim.keymap.set({'n', 'x'}, '<F3>', '<cmd>lua vim.lsp.buf.format({async = true})<cr>', opts) + vim.keymap.set('n', '<F4>', '<cmd>lua vim.lsp.buf.code_action()<cr>', opts) + end, + }, + config = function(_, opts) + opts.capabilities = require('cmp_nvim_lsp').default_capabilities() + require("lsp-zero").extend_lspconfig(opts) + end, + }, + -- Download plugins automatically + { 'williamboman/mason.nvim', config = true, }, + { + 'williamboman/mason-lspconfig.nvim', + lazy = false, + dependencies = { 'neovim/nvim-lspconfig' }, + opts = { + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, }, }, - setup = {}, }, } |
