|
@@ -16,7 +16,7 @@ local package_root = join_paths(temp_dir, "nvim", "site", "pack")
|
|
|
local install_path = join_paths(package_root, "packer", "start", "packer.nvim")
|
|
|
local compile_path = join_paths(install_path, "plugin", "packer_compiled.lua")
|
|
|
|
|
|
--- Choose whether to use the executable that's managed by lsp-installer
|
|
|
+-- Choose whether to use the executable that's managed by mason
|
|
|
local use_lsp_installer = true
|
|
|
|
|
|
local function load_plugins()
|
|
@@ -24,7 +24,8 @@ local function load_plugins()
|
|
|
{
|
|
|
"wbthomason/packer.nvim",
|
|
|
"neovim/nvim-lspconfig",
|
|
|
- { "williamboman/nvim-lsp-installer", disable = not use_lsp_installer },
|
|
|
+ "williamboman/mason-lspconfig.nvim",
|
|
|
+ "williamboman/mason.nvim",
|
|
|
},
|
|
|
config = {
|
|
|
package_root = package_root,
|
|
@@ -44,9 +45,6 @@ _G.load_config = function()
|
|
|
require("vim.lsp.log").set_format_func(vim.inspect)
|
|
|
local nvim_lsp = require "lspconfig"
|
|
|
local on_attach = function(_, bufnr)
|
|
|
- local function buf_set_keymap(...)
|
|
|
- vim.api.nvim_buf_set_keymap(bufnr, ...)
|
|
|
- end
|
|
|
local function buf_set_option(...)
|
|
|
vim.api.nvim_buf_set_option(bufnr, ...)
|
|
|
end
|
|
@@ -54,24 +52,26 @@ _G.load_config = function()
|
|
|
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.declaration()<CR>", opts)
|
|
|
- buf_set_keymap("n", "gd", "<Cmd>lua vim.lsp.buf.definition()<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", "<space>wa", "<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>wr", "<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>lD", "<cmd>lua vim.lsp.buf.type_definition()<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>lr", "<cmd>lua vim.lsp.buf.rename()<CR>", opts)
|
|
|
- buf_set_keymap("n", "gr", "<cmd>lua vim.lsp.buf.references()<CR>", opts)
|
|
|
- buf_set_keymap("n", "gl", "<cmd>lua vim.diagnostic.open_float(0,{scope='line'})<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>lk", "<cmd>lua vim.diagnostic.goto_prev()<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>lj", "<cmd>lua vim.diagnostic.goto_next()<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>lq", "<cmd>lua vim.diagnostic.setloclist()<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>li", "<cmd>LspInfo<CR>", opts)
|
|
|
- buf_set_keymap("n", "<space>lI", "<cmd>LspInstallInfo<CR>", opts)
|
|
|
+ local opts = { buffer = bufnr, noremap = true, silent = true }
|
|
|
+ vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts)
|
|
|
+ vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
|
|
|
+ vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
|
|
|
+ vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts)
|
|
|
+ vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts)
|
|
|
+ vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, opts)
|
|
|
+ vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, opts)
|
|
|
+ vim.keymap.set("n", "<space>wl", function()
|
|
|
+ print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
|
+ end, opts)
|
|
|
+ vim.keymap.set("n", "<space>lD", vim.lsp.buf.type_definition, opts)
|
|
|
+ vim.keymap.set("n", "<space>lr", vim.lsp.buf.rename, opts)
|
|
|
+ vim.keymap.set("n", "gr", vim.lsp.buf.references, opts)
|
|
|
+ vim.keymap.set("n", "gl", vim.diagnostic.open_float, opts)
|
|
|
+ vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
|
|
+ vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
|
|
+ vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, opts)
|
|
|
+ vim.keymap.set("n", "<space>li", "<cmd>LspInfo<CR>", opts)
|
|
|
+ vim.keymap.set("n", "<space>lI", "<cmd>MasonCR>", opts)
|
|
|
end
|
|
|
|
|
|
-- Add the server that troubles you here, e.g. "clangd", "pyright", "tsserver"
|
|
@@ -81,15 +81,6 @@ _G.load_config = function()
|
|
|
on_attach = on_attach,
|
|
|
}
|
|
|
|
|
|
- if use_lsp_installer then
|
|
|
- local server_available, server = require("nvim-lsp-installer.servers").get_server(name)
|
|
|
- if not server_available then
|
|
|
- server:install()
|
|
|
- end
|
|
|
- local default_opts = server:get_default_options()
|
|
|
- setup_opts = vim.tbl_deep_extend("force", setup_opts, default_opts)
|
|
|
- end
|
|
|
-
|
|
|
if not name then
|
|
|
print "You have not defined a server name, please edit minimal_init.lua"
|
|
|
end
|
|
@@ -99,6 +90,10 @@ _G.load_config = function()
|
|
|
end
|
|
|
|
|
|
nvim_lsp[name].setup(setup_opts)
|
|
|
+ if use_lsp_installer then
|
|
|
+ require("mason-lspconfig").setup { automatic_installation = true }
|
|
|
+ end
|
|
|
+
|
|
|
print [[You can find your log at $HOME/.cache/nvim/lsp.log. Please paste in a github issue under a details tag as described in the issue template.]]
|
|
|
end
|
|
|
|