From 98ea49a70f9219f0ec37538ab875031950c4a885 Mon Sep 17 00:00:00 2001 From: Oluwatobi Date: Sat, 31 May 2025 12:55:03 +0100 Subject: [PATCH] updated to 0.11 --- after/plugin/lsp-config.lua | 193 ++++++++++++++++++------------------ after/plugin/mason.lua | 1 - lazy-lock.json | 4 +- lua/plugins/lsp.lua | 41 ++++---- 4 files changed, 118 insertions(+), 121 deletions(-) delete mode 100644 after/plugin/mason.lua diff --git a/after/plugin/lsp-config.lua b/after/plugin/lsp-config.lua index d9d0a12e..57375182 100644 --- a/after/plugin/lsp-config.lua +++ b/after/plugin/lsp-config.lua @@ -1,102 +1,32 @@ --- [[ Configure LSP ]] -local lsp = require 'lsp-zero' - -lsp.preset 'recommended' - -lsp.ensure_installed { - 'rust_analyzer', - -- Python - -- 'mypy', - -- 'black', - -- 'isort', - -- 'ruff_lsp', - 'pyright', - -- Java Stuffs - 'jdtls', - -- 'google-java-format', - -- Golang - -- 'gofumpt', - -- 'goimports-reviser', - -- 'golines', - 'gopls', - 'templ', - 'htmx', - -- Typescript - -- 'prettier', - -- 'prettierd', - -- 'tsserver', - -- Others - 'tailwindcss', -} +require('mason').setup() +require('mason-lspconfig').setup() -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.foldingRange = { - dynamicRegistration = false, - lineFoldingOnly = true, -} +vim.lsp.enable 'rust_analyzer' +vim.lsp.enable 'pyright' --- Fix Undefined global 'vim' -lsp.nvim_workspace() - -local cmp = require 'cmp' -local cmp_select = { behavior = cmp.SelectBehavior.Select } -local cmp_mappings = lsp.defaults.cmp_mappings { - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm { select = true }, - [''] = cmp.mapping.complete(), -} +vim.lsp.enable 'jdtls' -cmp_mappings[''] = nil -cmp_mappings[''] = nil +vim.lsp.enable 'lua_ls' -lsp.setup_nvim_cmp { - mapping = cmp_mappings, -} +vim.lsp.enable 'gopls' +vim.lsp.enable 'templ' +vim.lsp.enable 'htmx' -lsp.set_preferences { - suggest_lsp_servers = false, - sign_icons = { - error = '⛔️', - warn = '⚠️', - hint = '🧐', - info = 'I', - }, -} +vim.lsp.enable 'jsonls' +vim.lsp.enable 'html' -local function on_attach(client, bufnr) - local opts = { buffer = bufnr, remap = false } +vim.lsp.enable 'ts_ls' +vim.lsp.enable 'eslint' - vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) - vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts) - vim.keymap.set('n', 'vws', vim.lsp.buf.workspace_symbol, opts) - vim.keymap.set('n', 'vd', vim.diagnostic.open_float, opts) - vim.keymap.set('n', '[d', vim.diagnostic.goto_next, opts) - vim.keymap.set('n', ']d', vim.diagnostic.goto_prev, opts) - vim.keymap.set('n', 'dd', vim.diagnostic.setloclist, opts) - vim.keymap.set('n', 'do', vim.diagnostic.open_float, opts) - vim.keymap.set('n', 'ca', vim.lsp.buf.code_action, opts) - vim.keymap.set('n', 'gd', require('telescope.builtin').lsp_definitions, opts) - vim.keymap.set('n', 'gr', require('telescope.builtin').lsp_references, opts) - vim.keymap.set('n', 'rn', vim.lsp.buf.rename, opts) - vim.keymap.set('n', 'lf', function() - require('conform').format() - end, { buffer = bufnr, desc = 'Format Buffer' }) - 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) -end - -lsp.on_attach(on_attach) -lsp.setup() +vim.lsp.enable 'tailwindcss' -vim.diagnostic.config { - virtual_text = true, +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities.textDocument.foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, } -local function on_attach(client, bufnr) +local function on_attach(bufnr) local opts = { buffer = bufnr, remap = false } vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) @@ -121,14 +51,79 @@ local function on_attach(client, bufnr) end, opts) end -lsp.on_attach(on_attach) -lsp.setup() - -vim.diagnostic.config { - virtual_text = true, -} +vim.api.nvim_create_autocmd('LspAttach', { + group = vim.api.nvim_create_augroup('UserLspConfig', {}), + callback = function(ev) + on_attach(ev.buf) + -- local map = function(keys, func, desc) + -- vim.keymap.set('n', keys, func, { buffer = ev.buf, desc = 'Lsp: ' .. desc }) + -- end + + -- local tele = require 'telescope.builtin' + -- map('gd', tele.lsp_definitions, 'Goto Definition') + -- map('gr', tele.lsp_references, 'Goto References') + -- + -- map('K', vim.lsp.buf.hover, 'hover') + -- + -- map('n', 'vws', vim.lsp.buf.workspace_symbol, 'Workspace Symbols') + -- + -- map('n', 'vd', vim.diagnostic.open_float, 'View Diagnostic') + -- + -- map('n', '[d', vim.diagnostic.goto_next, 'Goto Next Diagnostic') + -- map('n', ']d', vim.diagnostic.goto_prev, 'Goto Preview Diagnostic') + -- map('n', 'dd', vim.diagnostic.setloclist, 'List Diagnostics') + -- map('n', 'do', vim.diagnostic.open_float, 'List All Diagnostics') + -- map('n', 'ca', vim.lsp.buf.code_action, 'Code Action') + -- + -- map('fs', tele.lsp_document_symbols, 'Doc Symbols') + -- map('fS', tele.lsp_dynamic_workspace_symbols, 'Dynamic Symbols') + -- map('ft', tele.lsp_type_definitions, 'Goto Type') + -- map('fi', tele.lsp_implementations, 'Goto Impl') + -- + -- map('n', 'rn', vim.lsp.buf.rename, 'Rename') + -- map('n', 'lf', function() + -- require('conform').format() + -- end, 'Format Buffer') + -- + -- map('n', 'wa', vim.lsp.buf.add_workspace_folder, 'Add WorkSpace') + -- map('n', 'wr', vim.lsp.buf.remove_workspace_folder, 'Remove WorkSpace') + -- map('n', 'wl', function() + -- print(vim.inspect(vim.lsp.buf.list_workspace_folders())) + -- end, 'List Work Spaces') + end, +}) +-- vim.lsp.on_attach(on_attach) +-- vim.lsp.setup() +-- +-- vim.diagnostic.config { +-- virtual_text = true, +-- } -return { - capabilities = capabilities, - on_attach = on_attach, -} +-- Fix Undefined global 'vim' +-- vim.lsp.nvim_workspace() + +-- local cmp = require 'cmp' +-- local cmp_select = { behavior = cmp.SelectBehavior.Select } +-- local cmp_mappings = vim.lsp.defaults.cmp_mappings { +-- [''] = cmp.mapping.select_prev_item(cmp_select), +-- [''] = cmp.mapping.select_next_item(cmp_select), +-- [''] = cmp.mapping.confirm { select = true }, +-- [''] = cmp.mapping.complete(), +-- } + +-- cmp_mappings[''] = nil +-- cmp_mappings[''] = nil + +-- vim.lsp.setup_nvim_cmp { +-- mapping = cmp_mappings, +-- } + +-- vim.lsp.set_preferences { +-- suggest_lsp_servers = false, +-- sign_icons = { +-- error = '⛔️', +-- warn = '⚠️', +-- hint = '🧐', +-- info = 'I', +-- }, +-- } diff --git a/after/plugin/mason.lua b/after/plugin/mason.lua deleted file mode 100644 index e6117d29..00000000 --- a/after/plugin/mason.lua +++ /dev/null @@ -1 +0,0 @@ -require('mason').setup({}) diff --git a/lazy-lock.json b/lazy-lock.json index 8bd183dd..7be19d18 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -3,9 +3,11 @@ "alpha-nvim": { "branch": "main", "commit": "a35468cd72645dbd52c0624ceead5f301c566dff" }, "catppuccin": { "branch": "main", "commit": "387b4b19568cbda82c1d6def9ded31fd6ae7fb99" }, "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" }, + "cmp-cmdline": { "branch": "main", "commit": "d126061b624e0af6c3a556428712dd4d4194ec6d" }, "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" }, "cmp-nvim-lua": { "branch": "main", "commit": "f12408bdb54c39c23e67cab726264c10db33ada8" }, "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" }, + "cmp-vsnip": { "branch": "main", "commit": "989a8a73c44e926199bfd05fa7a516d51f2d2752" }, "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" }, "conform.nvim": { "branch": "master", "commit": "6feb2f28f9a9385e401857b21eeac3c1b66dd628" }, "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" }, @@ -15,7 +17,6 @@ "image.nvim": { "branch": "master", "commit": "4c51d6202628b3b51e368152c053c3fb5c5f76f2" }, "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, "lazygit.nvim": { "branch": "main", "commit": "b9eae3badab982e71abab96d3ee1d258f0c07961" }, - "lsp-zero.nvim": { "branch": "v1.x", "commit": "a7c18ecde0b4462bcd84f363723ff633f2c9a198" }, "lspkind-nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" }, "lua-async-await": { "branch": "main", "commit": "652d94df34e97abe2d4a689edbc4270e7ead1a98" }, "lualine.nvim": { "branch": "master", "commit": "0c6cca9f2c63dadeb9225c45bc92bb95a151d4af" }, @@ -56,5 +57,6 @@ "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" }, "vim-rhubarb": { "branch": "master", "commit": "386daa2e9d98e23e27ad089afcbe5c5a903e488d" }, "vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }, + "vim-vsnip": { "branch": "master", "commit": "0a4b8419e44f47c57eec4c90df17567ad4b1b36e" }, "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 4f669da9..c43e6473 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,25 +1,26 @@ return { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v1.x', - dependencies = { - -- LSP Support - { 'neovim/nvim-lspconfig' }, - { 'williamboman/mason.nvim' }, - { 'williamboman/mason-lspconfig.nvim' }, + 'neovim/nvim-lspconfig', + dependencies = { + -- LSP Support + { 'williamboman/mason.nvim' }, + { 'williamboman/mason-lspconfig.nvim' }, - -- Autocompletion - { 'hrsh7th/nvim-cmp' }, - { 'hrsh7th/cmp-buffer' }, - { 'hrsh7th/cmp-path' }, - { 'saadparwaiz1/cmp_luasnip' }, - { 'hrsh7th/cmp-nvim-lsp' }, - { 'hrsh7th/cmp-nvim-lua' }, + -- Autocompletion + { 'hrsh7th/nvim-cmp' }, + { 'hrsh7th/cmp-buffer' }, + { 'hrsh7th/cmp-path' }, + { 'saadparwaiz1/cmp_luasnip' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/cmp-nvim-lua' }, + { 'hrsh7th/cmp-cmdline' }, + { 'hrsh7th/cmp-vsnip' }, + { 'hrsh7th/vim-vsnip' }, - -- Snippets - { 'L3MON4D3/LuaSnip' }, + -- Snippets + { 'L3MON4D3/LuaSnip' }, - { 'rafamadriz/friendly-snippets' }, - }, - -- Use the lazy option to lazy-load the plugin on events or commands - lazy = true, + { 'rafamadriz/friendly-snippets' }, + }, + -- Use the lazy option to lazy-load the plugin on events or commands + lazy = true, }