diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 71aa355..719d43d 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -34,5 +34,6 @@ return { end, }, { 'nvim-tree/nvim-web-devicons', lazy = true }, + 'simrat39/rust-tools.nvim', -- { 'dstein64/vim-startuptime', lazy = false }, } diff --git a/lua/plugins/lsp/init.lua b/lua/plugins/lsp/init.lua index ceca3ec..02cb024 100644 --- a/lua/plugins/lsp/init.lua +++ b/lua/plugins/lsp/init.lua @@ -2,18 +2,14 @@ local M = { 'neovim/nvim-lspconfig', name = 'lsp', event = 'BufRead', - dependencies = { 'hrsh7th/cmp-nvim-lsp', 'williamboman/mason.nvim' }, -} - -local tools = { - 'clangd', - 'gopls', - 'sumneko_lua', - 'jdtls', + dependencies = { 'hrsh7th/cmp-nvim-lsp', 'williamboman/mason.nvim', 'williamboman/mason-lspconfig.nvim' }, } function M.config() - local lspconfig = require 'lspconfig' + require('mason-lspconfig').setup { + automatic_installation = false, + } + local opts = {} local cmp_nvim_lsp = require 'cmp_nvim_lsp' local capabilities = vim.lsp.protocol.make_client_capabilities() @@ -80,50 +76,59 @@ function M.config() -- util.info(client.name .. " " .. (enable and "yes" or "no"), "format") client.server_capabilities.documentFormattingProvider = enable end - for _, tool in ipairs(tools) do - opts = { - on_attach = on_attach, - capabilities = capabilities, - } - local server = vim.split(tool, '@')[1] - if server == 'sumneko_lua' then - local sumneko_opts = require 'plugins.lsp.settings.sumneko_lua' - opts = vim.tbl_deep_extend('force', sumneko_opts, opts) - end - if server == 'clangd' then - local clangd_flags = { - '--all-scopes-completion', - '--suggest-missing-includes', - '--background-index', - '--pch-storage=disk', - '--cross-file-rename', - '--log=info', - '--completion-style=detailed', - '--enable-config', -- clangd 11+ supports reading from .clangd configuration file - '--clang-tidy', - -- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", - -- "--fallback-style=Google", - -- "--header-insertion=never", - -- "--query-driver=" + require('mason-lspconfig').setup_handlers { + function(server) -- default handler (optional) + opts = { + on_attach = on_attach, + capabilities = capabilities, } - local clang_opts = { - arg = { unpack(clangd_flags) }, + + if server == 'sumneko_lua' then + local sumneko_opts = require 'plugins.lsp.settings.sumneko_lua' + opts = vim.tbl_deep_extend('force', sumneko_opts, opts) + end + if server == 'clangd' then + local clangd_flags = { + '--all-scopes-completion', + '--suggest-missing-includes', + '--background-index', + '--pch-storage=disk', + '--cross-file-rename', + '--log=info', + '--completion-style=detailed', + '--enable-config', -- clangd 11+ supports reading from .clangd configuration file + '--clang-tidy', + -- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", + -- "--fallback-style=Google", + -- "--header-insertion=never", + -- "--query-driver=" + } + local clang_opts = { + arg = { unpack(clangd_flags) }, + } + opts = vim.tbl_deep_extend('force', clang_opts, opts) + end + if server == 'jdtls' then + vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile()" + vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime()" + vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" + -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" + vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" + -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" + goto continue + end + require('lspconfig')[server].setup(opts) + ::continue:: + end, + ['rust_analyzer'] = function() + require('rust-tools').setup { + server = { + on_attach = on_attach, + } } - opts = vim.tbl_deep_extend('force', clang_opts, opts) - end - if server == 'jdtls' then - vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_compile JdtCompile lua require('jdtls').compile()" - vim.cmd "command! -buffer -nargs=? -complete=custom,v:lua.require'jdtls'._complete_set_runtime JdtSetRuntime lua require('jdtls').set_runtime()" - vim.cmd "command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()" - -- vim.cmd "command! -buffer JdtJol lua require('jdtls').jol()" - vim.cmd "command! -buffer JdtBytecode lua require('jdtls').javap()" - -- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()" - goto continue - end - lspconfig[server].setup(opts) - ::continue:: - end + end, + } local config = { virtual_text = { @@ -132,10 +137,10 @@ function M.config() signs = false, underline = true, update_in_insert = true, - severity_sort = true, + severity_sort = false, float = { - focusable = true, - style = 'minimal', + focusable = false, + -- style = 'minimal', border = 'rounded', source = 'always', header = '', diff --git a/lua/plugins/mason-nvim-dap.lua b/lua/plugins/mason-nvim-dap.lua index beddd3c..7c80b44 100644 --- a/lua/plugins/mason-nvim-dap.lua +++ b/lua/plugins/mason-nvim-dap.lua @@ -8,10 +8,40 @@ local M = { } function M.config() + local dap = require 'dap' require('mason-nvim-dap').setup { automatic_setup = true, } - require('mason-nvim-dap').setup_handlers() + require('mason-nvim-dap').setup_handlers { + function(source_name) + -- all sources with no handler get passed here + + -- Keep original functionality of `automatic_setup = true` + require 'mason-nvim-dap.automatic_setup'(source_name) + end, + elixir = function(source_name) + dap.adapters.mix_task = { + type = 'executable', + command = '/home/user/.local/share/nvim/mason/packages/elixir-ls/debugger.sh', -- debugger.bat for windows + args = {}, + } + dap.configurations.elixir = { + { + type = 'mix_task', + name = 'mix test', + task = 'test', + taskArgs = { '--trace' }, + request = 'launch', + startApps = true, -- for Phoenix projects + projectDir = '${workspaceFolder}', + requireFiles = { + 'test/**/test_helper.exs', + 'test/**/*_test.exs', + }, + }, + } + end, + } end return M diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index a46c821..d4629ce 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -42,9 +42,6 @@ function M.config() }, } -- M.check() - require('mason-lspconfig').setup { - automatic_installation = false, - } end return M