setup rust-tools, make lspconfig be handled by mason-lspconfig

This commit is contained in:
Volodymyr Patuta 2023-01-23 18:57:39 +01:00
parent 134e6ea0b0
commit d908d1dcce
4 changed files with 90 additions and 57 deletions

View File

@ -34,5 +34,6 @@ return {
end,
},
{ 'nvim-tree/nvim-web-devicons', lazy = true },
'simrat39/rust-tools.nvim',
-- { 'dstein64/vim-startuptime', lazy = false },
}

View File

@ -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,12 +76,13 @@ 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
require('mason-lspconfig').setup_handlers {
function(server) -- default handler (optional)
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'
@ -121,9 +118,17 @@ function M.config()
-- vim.cmd "command! -buffer JdtJshell lua require('jdtls').jshell()"
goto continue
end
lspconfig[server].setup(opts)
require('lspconfig')[server].setup(opts)
::continue::
end
end,
['rust_analyzer'] = function()
require('rust-tools').setup {
server = {
on_attach = on_attach,
}
}
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 = '',

View File

@ -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

View File

@ -42,9 +42,6 @@ function M.config()
},
}
-- M.check()
require('mason-lspconfig').setup {
automatic_installation = false,
}
end
return M