nvim: Replace nvim-lsp-installer with mason
This commit is contained in:
parent
92f5a69c3d
commit
8209624989
2 changed files with 129 additions and 14 deletions
125
neovim/init.lua
125
neovim/init.lua
|
|
@ -73,11 +73,6 @@ plugins = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"MarcWeber/vim-addon-local-vimrc",
|
"MarcWeber/vim-addon-local-vimrc",
|
||||||
{
|
|
||||||
"MunifTanjim/prettier.nvim",
|
|
||||||
dependencies = { "jose-elias-alvarez/null-ls.nvim" },
|
|
||||||
config = true,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"jose-elias-alvarez/null-ls.nvim",
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
|
@ -358,7 +353,125 @@ plugins = {
|
||||||
vim.keymap.set("", "<leader>cp", ":ContextPeek<CR>", { silent = true })
|
vim.keymap.set("", "<leader>cp", ":ContextPeek<CR>", { silent = true })
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{ "williamboman/nvim-lsp-installer", branch = "main" },
|
{
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
build = function(_plugin)
|
||||||
|
require("mason-registry").refresh()
|
||||||
|
end,
|
||||||
|
config = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"williamboman/mason-lspconfig.nvim",
|
||||||
|
dependencies = { "williamboman/mason.nvim" },
|
||||||
|
config = function(_plugin, opts)
|
||||||
|
local mason_lspconfig = require("mason-lspconfig")
|
||||||
|
mason_lspconfig.setup(opts)
|
||||||
|
|
||||||
|
local lsp_settings = {
|
||||||
|
rust_analyzer = {
|
||||||
|
["rust-analyzer"] = {
|
||||||
|
checkOnSave = {
|
||||||
|
command = "clippy",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
local on_attach = function(client, bufno)
|
||||||
|
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufno, ...) end
|
||||||
|
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufno, ...) end
|
||||||
|
|
||||||
|
-- Enable completion through omnifunc, triggered by <C-x><C-o>
|
||||||
|
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
|
-- Mappings.
|
||||||
|
local opts = { noremap=true, silent=true }
|
||||||
|
|
||||||
|
buf_set_keymap('n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>R', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
|
buf_set_keymap('v', '<Leader>ca', '<cmd>lua vim.lsp.buf.range_code_action()<CR>', opts)
|
||||||
|
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>d', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>j', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>k', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||||
|
buf_set_keymap('n', '<Leader>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
||||||
|
|
||||||
|
vim.api.nvim_command [[autocmd BufWritePre <buffer> lua vim.lsp.buf.format()]]
|
||||||
|
end
|
||||||
|
|
||||||
|
local default_setup = function(server_name)
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
|
require("lspconfig")[server_name].setup({
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = lsp_settings[server_name] or {},
|
||||||
|
capabilities = capabilities,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
mason_lspconfig.setup_handlers({
|
||||||
|
-- This is the default handler for servers not named below.
|
||||||
|
default_setup,
|
||||||
|
|
||||||
|
["rust_analyzer"] = function()
|
||||||
|
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||||
|
|
||||||
|
-- rust-analyzer will be configured by rust-tools. Don't use lspconfig
|
||||||
|
-- directly (or through the default setup) for this.
|
||||||
|
require('rust-tools').setup({
|
||||||
|
tools = {
|
||||||
|
autoSetHints = true,
|
||||||
|
hover_with_actions = false,
|
||||||
|
inlay_hints = {
|
||||||
|
only_current_line = true,
|
||||||
|
-- Parameter hints are more annoying than useful here. Neovim can't show
|
||||||
|
-- virtual text in the middle of the line like other editors do. It would
|
||||||
|
-- mess with grid-based motion anyway.
|
||||||
|
show_parameter_hints = false,
|
||||||
|
parameter_hints_prefix = "",
|
||||||
|
other_hints_prefix = "//",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
server = {
|
||||||
|
standalone = false,
|
||||||
|
capabilities = capabilities,
|
||||||
|
on_attach = on_attach,
|
||||||
|
settings = lsp_settings.rust_analyzer,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"jay-babu/mason-null-ls.nvim",
|
||||||
|
event = { "BufReadPre", "BufNewFile" },
|
||||||
|
dependencies = {
|
||||||
|
"jose-elias-alvarez/null-ls.nvim",
|
||||||
|
"williamboman/mason.nvim",
|
||||||
|
},
|
||||||
|
init = function()
|
||||||
|
local mason_null_ls = require("mason-null-ls")
|
||||||
|
local null_ls = require("null-ls")
|
||||||
|
|
||||||
|
mason_null_ls.setup({
|
||||||
|
handlers = {
|
||||||
|
black = function(source_name, methods)
|
||||||
|
null_ls.register(null_ls.builtins.formatting.black)
|
||||||
|
|
||||||
|
mason_null_ls.default_setup(source_name, methods)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
opts = {
|
opts = {
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,25 @@
|
||||||
{
|
{
|
||||||
"LuaSnip": { "branch": "master", "commit": "3d2ad0c0fa25e4e272ade48a62a185ebd0fe26c1" },
|
"LuaSnip": { "branch": "master", "commit": "c7984d1cca3d8615e4daefc196597872a0b8d590" },
|
||||||
"aerial.nvim": { "branch": "master", "commit": "c663d1b55f002930187a09b9eeb5bd0bad0ea23c" },
|
"aerial.nvim": { "branch": "master", "commit": "79644dbedc189d79573b2a60e247989bbd8f16e7" },
|
||||||
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
|
||||||
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
"cmp_luasnip": { "branch": "master", "commit": "18095520391186d634a0045dacaa346291096566" },
|
||||||
"context.vim": { "branch": "master", "commit": "108644e146c864995288dee7dacf219267917ac1" },
|
"context.vim": { "branch": "master", "commit": "108644e146c864995288dee7dacf219267917ac1" },
|
||||||
"fzf": { "branch": "master", "commit": "01302d097c39c3429de65424c6adb75fcac82187" },
|
"fzf": { "branch": "master", "commit": "01302d097c39c3429de65424c6adb75fcac82187" },
|
||||||
"gitsigns.nvim": { "branch": "main", "commit": "a36bc3360d584d39b4fb076d855c4180842d4444" },
|
"gitsigns.nvim": { "branch": "main", "commit": "a36bc3360d584d39b4fb076d855c4180842d4444" },
|
||||||
"lazy.nvim": { "branch": "main", "commit": "b7043f2983d7aead78ca902f3f2053907081859a" },
|
"lazy.nvim": { "branch": "main", "commit": "4c8b625bc873ca76b76eee0c28c98f1f7148f17f" },
|
||||||
"lush.nvim": { "branch": "main", "commit": "789a2fbd98f3572f315958a0e8a711eb88d360d8" },
|
"lush.nvim": { "branch": "main", "commit": "789a2fbd98f3572f315958a0e8a711eb88d360d8" },
|
||||||
|
"mason-lspconfig.nvim": { "branch": "main", "commit": "4f1c72767bec31397d59554f84096909b2887195" },
|
||||||
|
"mason-null-ls.nvim": { "branch": "main", "commit": "73c68abdf65279e41526eb152876511a8ae84ea2" },
|
||||||
|
"mason.nvim": { "branch": "main", "commit": "b68d3be4b664671002221d43c82e74a0f1006b26" },
|
||||||
"nerdtree": { "branch": "master", "commit": "c46e12a886b4a6618a9e834c90f6245952567115" },
|
"nerdtree": { "branch": "master", "commit": "c46e12a886b4a6618a9e834c90f6245952567115" },
|
||||||
"nui.nvim": { "branch": "main", "commit": "d146966a423e60699b084eeb28489fe3b6427599" },
|
"nui.nvim": { "branch": "main", "commit": "d146966a423e60699b084eeb28489fe3b6427599" },
|
||||||
"null-ls.nvim": { "branch": "main", "commit": "bbaf5a96913aa92281f154b08732be2f57021c45" },
|
"null-ls.nvim": { "branch": "main", "commit": "aac27a1fa550de3d0b2c651168167cc0d5366a9a" },
|
||||||
"nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" },
|
"nvim-autopairs": { "branch": "master", "commit": "e8f7dd7a72de3e7b6626c050a802000e69d53ff0" },
|
||||||
"nvim-cmp": { "branch": "main", "commit": "e1f1b40790a8cb7e64091fb12cc5ffe350363aa0" },
|
"nvim-cmp": { "branch": "main", "commit": "e1f1b40790a8cb7e64091fb12cc5ffe350363aa0" },
|
||||||
"nvim-lsp-installer": { "branch": "main", "commit": "17e0bfa5f2c8854d1636fcd036dc8284db136baa" },
|
"nvim-lspconfig": { "branch": "master", "commit": "5da57456597ac2f25f20d6ecfae7b7c9cbd01fc6" },
|
||||||
"nvim-lspconfig": { "branch": "master", "commit": "b6b34b9acf84949f0ac1c00747765e62b81fb38d" },
|
|
||||||
"nvim-surround": { "branch": "main", "commit": "10b20ca7d9da1ac8df8339e140ffef94f9ab3b18" },
|
"nvim-surround": { "branch": "main", "commit": "10b20ca7d9da1ac8df8339e140ffef94f9ab3b18" },
|
||||||
"nvim-treesitter": { "branch": "master", "commit": "f26596386f31d5bd74b85b7d1ab0fd90c5b98608" },
|
"nvim-treesitter": { "branch": "master", "commit": "8d2eb35c5b72a2e2fdb713998bdc906d8f028114" },
|
||||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "83c59ed1eeae70a55605990993cf4d208948fdf7" },
|
"nvim-treesitter-textobjects": { "branch": "master", "commit": "52f1f3280d9092bfaee5c45be5962fabee3d9654" },
|
||||||
"openingh.nvim": { "branch": "main", "commit": "2719e5759ecf4b9a2d492fbf52d03d2e6fc6126a" },
|
"openingh.nvim": { "branch": "main", "commit": "2719e5759ecf4b9a2d492fbf52d03d2e6fc6126a" },
|
||||||
"plenary.nvim": { "branch": "master", "commit": "36aaceb6e93addd20b1b18f94d86aecc552f30c4" },
|
"plenary.nvim": { "branch": "master", "commit": "36aaceb6e93addd20b1b18f94d86aecc552f30c4" },
|
||||||
"prettier.nvim": { "branch": "main", "commit": "d98e732cb73690b07c00c839c924be1d1d9ac5c2" },
|
"prettier.nvim": { "branch": "main", "commit": "d98e732cb73690b07c00c839c924be1d1d9ac5c2" },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue