diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-09-18 23:13:11 +0200 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-09-18 23:13:11 +0200 |
| commit | af18201866ea29d179fd61bacd36b849a7d86a7d (patch) | |
| tree | f91a593c1eac7e5cee50ed470fde903e0ae7ad17 | |
| parent | f64a1630423087bb020c2c0ea341136abd725c38 (diff) | |
| download | nvim-conf-af18201866ea29d179fd61bacd36b849a7d86a7d.tar.gz nvim-conf-af18201866ea29d179fd61bacd36b849a7d86a7d.zip | |
refactor lsp configurations
| -rw-r--r-- | lazy-lock.json | 41 | ||||
| -rw-r--r-- | lua/alpha/lsp/attach.lua | 1 | ||||
| -rw-r--r-- | lua/alpha/lsp/default.lua | 26 | ||||
| -rw-r--r-- | lua/alpha/lsp/flags.lua | 3 | ||||
| -rw-r--r-- | lua/alpha/lsp/init.lua | 68 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers.lua | 173 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/emmet_ls.lua | 12 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/html.lua | 14 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/jsonls.lua | 14 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/lua_ls.lua | 29 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/phpactor.lua | 28 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/rust_analyzer.lua | 24 | ||||
| -rw-r--r-- | lua/alpha/lsp/servers/tsserver.lua | 33 | ||||
| -rw-r--r-- | lua/alpha/telescope/init.lua | 8 | ||||
| -rw-r--r-- | lua/plugins/lsp.lua | 34 |
15 files changed, 278 insertions, 230 deletions
diff --git a/lazy-lock.json b/lazy-lock.json index a9b2ce1..a2e2873 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -20,10 +20,10 @@ "direnv.vim": { "branch": "master", "commit": "165031fa2c8dbb1e78dfd7054fe064ea926384cb" }, "dressing.nvim": { "branch": "master", "commit": "c1e1d5fa44fe08811b6ef4aadac2b50e602f9504" }, "duck.nvim": { "branch": "main", "commit": "8f18dd79c701698fc150119ef642c1881ce6a538" }, - "fzf": { "branch": "master", "commit": "eb4bbf32948303e326a2791c6a875f32d7b5c97f" }, - "fzf.vim": { "branch": "master", "commit": "587f55bf5051ff40600837778ea01ead6283f399" }, + "fzf": { "branch": "master", "commit": "d2b852f7cbd2da53804de00cf22ca0b7e6c9f472" }, + "fzf.vim": { "branch": "master", "commit": "678ee1a549bd873dde35f6146f288a3f2e29d983" }, "git-worktree.nvim": { "branch": "master", "commit": "d7f4e2584e81670154f07ca9fa5dd791d9c1b458" }, - "gitsigns.nvim": { "branch": "main", "commit": "fef5d90953f0a730483b44745fae5938ba8227f8" }, + "gitsigns.nvim": { "branch": "main", "commit": "bce4576a9047085a528c479a7fe1e2f6b787b6c1" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, "hydra.nvim": { "branch": "master", "commit": "3ced42c0b6a6c85583ff0f221635a7f4c1ab0dd0" }, "icon-picker.nvim": { "branch": "master", "commit": "e6dca182518eeb7a51470c13605a5bce08a816e4" }, @@ -33,17 +33,17 @@ "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, "markdown-preview.nvim": { "branch": "main", "commit": "cc05a30393e2bf9f12e2d59fc35a1aa928ed1727" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "20fd7f50f34b59031a7c3bbc2c207f4f60037628" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "f014db32437aa61c86fc0ef1067cd2bc6a37205c" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "031903fefbf59371502092ef9e22cab9161d90ba" }, "mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" }, "middleclass": { "branch": "master", "commit": "9fab4d5bca67262614960960ca35c4740eb2be2c" }, - "neodev.nvim": { "branch": "main", "commit": "f0e574687aa51c513017155f003e8e8950ec6ff4" }, + "neodev.nvim": { "branch": "main", "commit": "471324e6c746284dbbdc1d357799d1911bb7e120" }, "neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" }, - "neorg": { "branch": "main", "commit": "851a3a2b3cea5335fca233273d3c8861a017da14" }, + "neorg": { "branch": "main", "commit": "0d2491792691cab07cc2eaae3a1e692a24be18cd" }, "neotest": { "branch": "master", "commit": "1e67a504d03def3a6a1125d934cb511680f72555" }, "neotest-go": { "branch": "main", "commit": "1a15e1136db43775214a3e7a598f8930c29c94b7" }, "neotest-plenary": { "branch": "master", "commit": "e0d9b1530307a03abcc52fc0ae28f054dea3f752" }, - "neotest-rust": { "branch": "main", "commit": "dd49d0de3a4ccde0c8ce99dbae9e7b04bcdbfc85" }, + "neotest-rust": { "branch": "main", "commit": "c8894d826a2cb5003cb6bc0a2fa8f7a359899130" }, "neotest-vim-test": { "branch": "master", "commit": "75c4228882ae4883b11bfce9b8383e637eb44192" }, "noice.nvim": { "branch": "main", "commit": "74c2902146b080035beb19944baf6f014a954720" }, "nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" }, @@ -52,43 +52,42 @@ "nvim-autopairs": { "branch": "master", "commit": "defad64afbf19381fe31488a7582bbac421d6e38" }, "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, "nvim-colorizer.lua": { "branch": "master", "commit": "36c610a9717cc9ec426a07c8e6bf3b3abcb139d6" }, - "nvim-dap": { "branch": "master", "commit": "0e6b7c47dd70e80793ed39271b2aa712d9366dbc" }, + "nvim-dap": { "branch": "master", "commit": "b3d4408e29d924fe130c9397a7c3b3630b3ea671" }, "nvim-dap-go": { "branch": "main", "commit": "1b508e9db330108d3b5d62a6d9cc01fe6bbdd4e0" }, "nvim-dap-ui": { "branch": "master", "commit": "34160a7ce6072ef332f350ae1d4a6a501daf0159" }, "nvim-dap-virtual-text": { "branch": "master", "commit": "57f1dbd0458dd84a286b27768c142e1567f3ce3b" }, "nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" }, - "nvim-lspconfig": { "branch": "master", "commit": "0d24eeafb5b531c7fac610a3508207f33c76ce6d" }, + "nvim-lspconfig": { "branch": "master", "commit": "f3195835c0447ee2c80152b893ab51ca162b04a9" }, "nvim-notify": { "branch": "master", "commit": "94859430020f5cf32a1b97ddd9e596fed9db7981" }, - "nvim-spectre": { "branch": "master", "commit": "411cee67fe3f8242023eb8d9edafefbbfb2d06f1" }, + "nvim-spectre": { "branch": "master", "commit": "97cfd1b0f5a6ab35979ce1bee6c17f54745fd1e5" }, "nvim-transparent": { "branch": "main", "commit": "3af6232c8d39d51062702e875ff6407c1eeb0391" }, - "nvim-treesitter": { "branch": "master", "commit": "15d327fe6324d8269451131ec34ad4f2a8ef1e01" }, + "nvim-treesitter": { "branch": "master", "commit": "b4f6dd72980607a9821d24502b0ca7ee826376af" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" }, - "nvim-web-devicons": { "branch": "master", "commit": "925e2aa30dc9fe9332060199c19f132ec0f3d493" }, - "plenary.nvim": { "branch": "master", "commit": "0232372b906f275f76ac42029eba25eaf95e76b9" }, + "nvim-web-devicons": { "branch": "master", "commit": "973ab742f143a796a779af4d786ec409116a0d87" }, + "plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" }, "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" }, - "refactoring.nvim": { "branch": "master", "commit": "2ec9bc0fb5f3c8c6a0f776f0159dd2a3b1663554" }, - "smart-splits.nvim": { "branch": "master", "commit": "7aad6019dee974a01333523a5b8e122b7e7da454" }, + "refactoring.nvim": { "branch": "master", "commit": "be6505be8bdd306646bb81399312c02927a60a51" }, + "smart-splits.nvim": { "branch": "master", "commit": "0beb14427dcf2a5d5d63e0064b45032a7bd3e763" }, "telescope-dap.nvim": { "branch": "master", "commit": "4e2d5efb92062f0b865fe59b200b5ed7793833bf" }, - "telescope-file-browser.nvim": { "branch": "master", "commit": "ad7b637c72549713b9aaed7c4f9c79c62bcbdff0" }, + "telescope-file-browser.nvim": { "branch": "master", "commit": "bec4b0fd6c293f5c42d7929d8eff49e5af43e7f3" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" }, "telescope-fzy-native.nvim": { "branch": "master", "commit": "282f069504515eec762ab6d6c89903377252bf5b" }, "telescope-ui-select.nvim": { "branch": "master", "commit": "62ea5e58c7bbe191297b983a9e7e89420f581369" }, - "telescope.nvim": { "branch": "master", "commit": "a19770625aed49ad2a9f591a5e3946707f7359f6" }, + "telescope.nvim": { "branch": "master", "commit": "b543aaa2c9cf8123ed2fe7dbb6c211a9cd415124" }, "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, "trouble.nvim": { "branch": "main", "commit": "3f85d8ed30e97ceeddbbcf80224245d347053711" }, "twilight.nvim": { "branch": "main", "commit": "a4843e6e67092a1e6fa9666f02bf0ab59174c1df" }, - "vim-blade": { "branch": "master", "commit": "9534101808cc320eef003129a40cab04b026a20c" }, "vim-dadbod": { "branch": "master", "commit": "7d80bbd11c407a09e0f7b869c38f3dec3902805f" }, "vim-dadbod-completion": { "branch": "master", "commit": "fc7321a17f4c55db11fae89a884ddf4724020bae" }, - "vim-dadbod-ui": { "branch": "master", "commit": "200aebf70e6fc4b0eb1d3ecf0d57028e198d8dc6" }, + "vim-dadbod-ui": { "branch": "master", "commit": "0df3e984ba43d1688e4223315b4f27cbb556f6ad" }, "vim-dispatch": { "branch": "master", "commit": "6cc2691576f97d43f8751664d1a1a908b99927e5" }, "vim-dotenv": { "branch": "master", "commit": "5c51cfcf8d87280d6414e03cd6b253eb70ecb800" }, "vim-easy-align": { "branch": "master", "commit": "12dd6316974f71ce333e360c0260b4e1f81169c3" }, "vim-enfocado": { "branch": "main", "commit": "845835a58d285eb8c1ced5dba83bfdec6e40d828" }, "vim-eunuch": { "branch": "master", "commit": "67f3dd32b4dcd1c427085f42ff5f29c7adc645c6" }, - "vim-fugitive": { "branch": "master", "commit": "6fcb0ad03982de646e3fecb6915e585651b9a9fb" }, + "vim-fugitive": { "branch": "master", "commit": "99db68d9b3304580bd383da7aaee05c7a954a344" }, "vim-repeat": { "branch": "master", "commit": "24afe922e6a05891756ecf331f39a1f6743d3d5a" }, "vim-rhubarb": { "branch": "master", "commit": "ee69335de176d9325267b0fd2597a22901d927b1" }, "vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" }, - "vim-test": { "branch": "master", "commit": "7585ad2aa2dc8d4ffef0739a02cad8a30d75bfbb" } + "vim-test": { "branch": "master", "commit": "a007258adc7b319943bf71dfead88d2ad721b923" } }
\ No newline at end of file diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua index 6fc415c..a6d5257 100644 --- a/lua/alpha/lsp/attach.lua +++ b/lua/alpha/lsp/attach.lua @@ -56,6 +56,7 @@ local filetype_attach = setmetatable({ return function() end end, }) + return function(client, bufnr) local filetype = vim.api.nvim_buf_get_option(0, "filetype") -- keymaps for lsp diff --git a/lua/alpha/lsp/default.lua b/lua/alpha/lsp/default.lua new file mode 100644 index 0000000..a1b1e25 --- /dev/null +++ b/lua/alpha/lsp/default.lua @@ -0,0 +1,26 @@ +return { + mason = { + enable = true, + auto_install = false, + }, + servers = { + emmet_ls = { enable = true }, + gopls = { enable = true }, + html = { enable = true }, + jsonls = { enable = true }, + lua_ls = { enable = true }, + nil_ls = { enable = true }, + phpactor = {enable = true }, + rust_analyzer = { enable = true }, + svelte = { enable = true }, + tailwindcss = { enable = true, filetypes = {"blade", "html", "svelte"} }, + tsserver = { enable = true }, + volar = { enable = true }, + }, + default_options = function (options) + return vim.tbl_deep_extend("force", { + on_attach = require"alpha.lsp.attach", + flags = require "alpha.lsp.flags", + }, options) + end, +} diff --git a/lua/alpha/lsp/flags.lua b/lua/alpha/lsp/flags.lua new file mode 100644 index 0000000..f70b467 --- /dev/null +++ b/lua/alpha/lsp/flags.lua @@ -0,0 +1,3 @@ +return { + debounce_text_changes = 150, +} diff --git a/lua/alpha/lsp/init.lua b/lua/alpha/lsp/init.lua index 03bd61d..0d4a85d 100644 --- a/lua/alpha/lsp/init.lua +++ b/lua/alpha/lsp/init.lua @@ -1,12 +1,62 @@ --- LSP configuration +return { + setup = function(ops) + ops = vim.tbl_deep_extend("force", require "alpha.lsp.default", ops) -local lspconfig = require "lspconfig" -local servers = require "alpha.lsp.servers" + local lspconfig = require "lspconfig" -for server, setup in pairs(servers) do - lspconfig[server].setup(setup()) -end + local mason_servers = {} + for server, options in pairs(ops.servers) do + if options.enable == true then + local ok, definition = pcall(require, "alpha.lsp.servers." .. server) + local server_options + if not ok then + server_options = ops.default_options(options) + else + server_options = definition(options) + end + lspconfig[server].setup(server_options) + table.insert(mason_servers, server) + end + end --- install servers and tools -require "alpha.lsp.mason" -require "alpha.lsp.null-ls" + -- Mason + if ops.mason.enable then + local mason_ops = {} + if ops.mason.auto_install == true then + mason_ops.ensure_installed = mason_servers + end + local mason_lspconfig = require "mason-lspconfig" + mason_lspconfig.setup(mason_ops) + end + + -- TODO: implement null ls with options + require "alpha.lsp.null-ls" + + local servers = {} + for server, options in pairs(ops.servers) do + table.insert(servers, string.format("%s <%s>", server, options.enable)) + end + + vim.api.nvim_create_user_command("AlphaLSP", function() + vim.ui.select(servers, { prompt = "LSP Servers" }, function(server) + if server == nil then + return + end + + server = string.match(server, "^(.+) <") + local path = string.format("%s/lua/alpha/lsp/servers/%s.lua", vim.fn.stdpath "config", server) + if vim.fn.filereadable(path) == 0 then + local create = vim.fn.confirm("Server Does Not exist. Create new server?", "&Yes\n&No\n&Cancel") + if create ~= 1 then + return + end + end + + local uri = vim.uri_from_fname(path) + local buffer = vim.uri_to_bufnr(uri) + + vim.api.nvim_win_set_buf(0, buffer) + end) + end, {}) + end, +} diff --git a/lua/alpha/lsp/servers.lua b/lua/alpha/lsp/servers.lua deleted file mode 100644 index e9acc4b..0000000 --- a/lua/alpha/lsp/servers.lua +++ /dev/null @@ -1,173 +0,0 @@ -local lsp_attach = require "alpha.lsp.attach" - -local lsp_flags = { - debounce_text_changes = 150, -} - -local default = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - } -end - -return { - ["emmet_ls"] = function() - local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) - - return { - on_attach = lsp_attach, - flags = lsp_flags, - capabilities = capabilities, - filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" }, - } - end, - ["gopls"] = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - } - end, - ["html"] = function() - local config = { - on_attach = lsp_attach, - flags = lsp_flags, - } - if vim.fn.executable "html-languageserver" == 1 then - config.cmd = { "html-languageserver", "--stdio" } - end - - return config - end, - ["jsonls"] = function() - local config = { - on_attach = lsp_attach, - flags = lsp_flags, - } - if vim.fn.executable "json-languageserver" == 1 then - config.cmd = { "json-languageserver", "--stdio" } - end - - return config - end, - ["lua_ls"] = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - Lua = { - runtime = { - version = "LuaJIT", - }, - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = vim.api.nvim_get_runtime_file("", true), - checkThirdParty = false, - }, - telemetry = { - enable = false, - }, - hint = { - enable = true, - }, - }, - }, - } - end, - ["omnisharp"] = function() - return { - cmd = { "OmniSharp" }, - on_attach = lsp_attach, - flags = lsp_flags, - } - end, - ["nil_ls"] = default, - ["phpactor"] = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - filetypes = { "php" }, - init_options = { - ["language_server_worse_reflection.inlay_hints.enable"] = true, - ["language_server_worse_reflection.inlay_hints.params"] = true, - -- ["language_server_worse_reflection.inlay_hints.types"] = true, - ["language_server_configuration.auto_config"] = false, - ["code_transform.import_globals"] = true, - ["language_server_phpstan.enabled"] = true, - ["language_server_phpstan.level"] = 7, - ["language_server_phpstan.bin"] = "phpstan", - }, - handlers = { - ["textDocument/inlayHint"] = function(err, result, ...) - for _, res in ipairs(result) do - res.label = res.label .. ": " - end - vim.lsp.handlers["textDocument/inlayHint"](err, result, ...) - end, - }, - } - end, - ["pyright"] = default, - ["rust_analyzer"] = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - ["rust-analyzer"] = { - checkOnSave = { - allFeatures = true, - overrideCommand = { - "cargo", - "clippy", - "--workspace", - "--message-format=json", - "--all-targets", - "--all-features", - }, - }, - }, - }, - } - end, - ["svelte"] = default, - ["tailwindcss"] = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - filetypes = { "blade", "html", "svelte" }, - } - end, - ["tsserver"] = function() - return { - on_attach = lsp_attach, - flags = lsp_flags, - settings = { - typescript = { - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - javascript = { - inlayHints = { - includeInlayParameterNameHints = "all", - includeInlayParameterNameHintsWhenArgumentMatchesName = false, - includeInlayFunctionParameterTypeHints = true, - includeInlayVariableTypeHints = true, - includeInlayPropertyDeclarationTypeHints = true, - includeInlayFunctionLikeReturnTypeHints = true, - includeInlayEnumMemberValueHints = true, - }, - }, - }, - } - end, - ["volar"] = default, -} diff --git a/lua/alpha/lsp/servers/emmet_ls.lua b/lua/alpha/lsp/servers/emmet_ls.lua new file mode 100644 index 0000000..c4f1cb6 --- /dev/null +++ b/lua/alpha/lsp/servers/emmet_ls.lua @@ -0,0 +1,12 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require "alpha.lsp.flags" + +return function(ops) + local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + return vim.tbl_extend("force", { + on_attach = lsp_attach, + flags = lsp_flags, + capabilities = capabilities, + filetypes = { "html", "typescriptreact", "javascriptreact", "css", "sass", "scss", "less", "blade", "vue" }, + }, ops) +end diff --git a/lua/alpha/lsp/servers/html.lua b/lua/alpha/lsp/servers/html.lua new file mode 100644 index 0000000..7b8ef54 --- /dev/null +++ b/lua/alpha/lsp/servers/html.lua @@ -0,0 +1,14 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require "alpha.lsp.flags" + +return function(ops) + local config = { + on_attach = lsp_attach, + flags = lsp_flags, + } + if vim.fn.executable "html-languageserver" == 1 then + config.cmd = { "html-languageserver", "--stdio" } + end + + return vim.tbl_extend("force", config, ops) +end diff --git a/lua/alpha/lsp/servers/jsonls.lua b/lua/alpha/lsp/servers/jsonls.lua new file mode 100644 index 0000000..9c731ab --- /dev/null +++ b/lua/alpha/lsp/servers/jsonls.lua @@ -0,0 +1,14 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require "alpha.lsp.flags" + +return function(ops) + local config = { + on_attach = lsp_attach, + flags = lsp_flags, + } + if vim.fn.executable "json-languageserver" == 1 then + config.cmd = { "json-languageserver", "--stdio" } + end + + return vim.tbl_extend("force", config, ops) +end diff --git a/lua/alpha/lsp/servers/lua_ls.lua b/lua/alpha/lsp/servers/lua_ls.lua new file mode 100644 index 0000000..64f012c --- /dev/null +++ b/lua/alpha/lsp/servers/lua_ls.lua @@ -0,0 +1,29 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require("alpha.lsp.flags") + +return function(ops) + return vim.tbl_extend("force", { + on_attach = lsp_attach, + flags = lsp_flags, + settings = { + Lua = { + runtime = { + version = "LuaJIT", + }, + diagnostics = { + globals = { "vim" }, + }, + workspace = { + library = vim.api.nvim_get_runtime_file("", true), + checkThirdParty = false, + }, + telemetry = { + enable = false, + }, + hint = { + enable = true, + }, + }, + }, + }, ops) +end diff --git a/lua/alpha/lsp/servers/phpactor.lua b/lua/alpha/lsp/servers/phpactor.lua new file mode 100644 index 0000000..fd25568 --- /dev/null +++ b/lua/alpha/lsp/servers/phpactor.lua @@ -0,0 +1,28 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require "alpha.lsp.flags" + +return function(ops) + return vim.tbl_extend("force", { + on_attach = lsp_attach, + flags = lsp_flags, + filetypes = { "php", "blade" }, + init_options = { + ["language_server_worse_reflection.inlay_hints.enable"] = true, + ["language_server_worse_reflection.inlay_hints.params"] = true, + -- ["language_server_worse_reflection.inlay_hints.types"] = true, + ["language_server_configuration.auto_config"] = false, + ["code_transform.import_globals"] = true, + ["language_server_phpstan.enabled"] = true, + ["language_server_phpstan.level"] = 7, + ["language_server_phpstan.bin"] = "phpstan", + }, + handlers = { + ["textDocument/inlayHint"] = function(err, result, ...) + for _, res in ipairs(result) do + res.label = res.label .. ": " + end + vim.lsp.handlers["textDocument/inlayHint"](err, result, ...) + end, + }, + }, ops) +end diff --git a/lua/alpha/lsp/servers/rust_analyzer.lua b/lua/alpha/lsp/servers/rust_analyzer.lua new file mode 100644 index 0000000..c0db321 --- /dev/null +++ b/lua/alpha/lsp/servers/rust_analyzer.lua @@ -0,0 +1,24 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require "alpha.lsp.flags" + +return function(ops) + return vim.tbl_extend("force", { + on_attach = lsp_attach, + flags = lsp_flags, + settings = { + ["rust-analyzer"] = { + checkOnSave = { + allFeatures = true, + overrideCommand = { + "cargo", + "clippy", + "--workspace", + "--message-format=json", + "--all-targets", + "--all-features", + }, + }, + }, + }, + }, ops) +end diff --git a/lua/alpha/lsp/servers/tsserver.lua b/lua/alpha/lsp/servers/tsserver.lua new file mode 100644 index 0000000..e27d94a --- /dev/null +++ b/lua/alpha/lsp/servers/tsserver.lua @@ -0,0 +1,33 @@ +local lsp_attach = require "alpha.lsp.attach" +local lsp_flags = require "alpha.lsp.flags" + +return function(ops) + return vim.tbl_extend("force", { + on_attach = lsp_attach, + flags = lsp_flags, + settings = { + typescript = { + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + javascript = { + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = true, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + }, + }, ops) +end diff --git a/lua/alpha/telescope/init.lua b/lua/alpha/telescope/init.lua index c67b074..c4daf6c 100644 --- a/lua/alpha/telescope/init.lua +++ b/lua/alpha/telescope/init.lua @@ -137,10 +137,6 @@ function M.refactor() return require("telescope").extensions.refactoring.refactors() end -function M.file_browser_relative() - return M.file_browser { path = "%:p:h" } -end - function M.gateway() return require("alpha.php.gateway").graphql_definitions { layout_config = { @@ -153,6 +149,10 @@ function M.gateway() } end +function M.file_browser_relative() + return M.file_browser { path = "%:p:h" } +end + function M.file_browser(opts) opts = opts or {} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 1c0a855..60ea560 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -1,12 +1,7 @@ return { "neovim/nvim-lspconfig", dependencies = { - { - "jose-elias-alvarez/null-ls.nvim", - dependencies = { - "adalessa/php-code-actions.nvim", - }, - }, + "jose-elias-alvarez/null-ls.nvim", { "williamboman/mason.nvim", opts = { @@ -17,23 +12,16 @@ return { }, "williamboman/mason-lspconfig.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim", - { - "j-hui/fidget.nvim", - enabled = false, - opts = { - window = { - blend = 0, - }, - sources = { - ["null-ls"] = { - ignore = true, - }, - }, - }, - }, }, event = "VeryLazy", - config = function() - require "alpha.lsp" - end, + main = "alpha.lsp", + opts = { + mason = { + enable = true, + auto_install = false, + }, + servers = { + phpactor = { enable = true }, + }, + }, } |