Moved from custom LSP installs to LspInstall
This commit is contained in:
parent
94c37fc66a
commit
da38421d7b
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -8,3 +8,5 @@ __pycache__/
|
||||||
*.pickle
|
*.pickle
|
||||||
*.spl
|
*.spl
|
||||||
neovim/.config/nvim/plugin/
|
neovim/.config/nvim/plugin/
|
||||||
|
wget-log*
|
||||||
|
*log*
|
||||||
|
|
|
@ -4,6 +4,9 @@ local opt=vim.opt
|
||||||
local fn=vim.fn
|
local fn=vim.fn
|
||||||
local map=vim.api.nvim_set_keymap
|
local map=vim.api.nvim_set_keymap
|
||||||
|
|
||||||
|
--leader key is set through a variable, for some reason.
|
||||||
|
vim.g.mapleader = ';'
|
||||||
|
|
||||||
--do package management
|
--do package management
|
||||||
require('packages')
|
require('packages')
|
||||||
require('LSPconfig')
|
require('LSPconfig')
|
||||||
|
@ -64,9 +67,6 @@ require('cmp-lsp')
|
||||||
opt.foldenable=true
|
opt.foldenable=true
|
||||||
opt.foldignore=''
|
opt.foldignore=''
|
||||||
|
|
||||||
--leader key is set through a variable, for some reason.
|
|
||||||
vim.g.mapleader = ';'
|
|
||||||
|
|
||||||
--sets colorscheme. to get a list of avalible options, do colorscheme <Space> <C-d>
|
--sets colorscheme. to get a list of avalible options, do colorscheme <Space> <C-d>
|
||||||
vim.cmd 'colorscheme moonfly'
|
vim.cmd 'colorscheme moonfly'
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,51 @@
|
||||||
local nvim_lsp = require('lspconfig')
|
local lsp_installer = require("nvim-lsp-installer")
|
||||||
|
|
||||||
|
|
||||||
|
-- Include the servers you want to have installed by default below
|
||||||
|
local install_servers=function()
|
||||||
|
local servers = {
|
||||||
|
'pyright',
|
||||||
|
'bashls',
|
||||||
|
'rust_analyzer',
|
||||||
|
'sumenko_lua',
|
||||||
|
'ltex',
|
||||||
|
'texlab',
|
||||||
|
}
|
||||||
|
|
||||||
|
local flag=false;
|
||||||
|
for _, name in pairs(servers) do
|
||||||
|
local server_is_found, server = lsp_installer.get_server(name)
|
||||||
|
if server_is_found and not server:is_installed() then
|
||||||
|
print("Installing " .. name)
|
||||||
|
server:install()
|
||||||
|
flag=true;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if flag then
|
||||||
|
print('All Servers Installed')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
lsp_installer.on_server_ready(function(server)
|
||||||
|
local opts = {}
|
||||||
|
|
||||||
|
if server.name == "rust_analyzer" then
|
||||||
|
-- Initialize the LSP via rust-tools instead
|
||||||
|
require("rust-tools").setup {
|
||||||
|
-- The "server" property provided in rust-tools setup function are the
|
||||||
|
-- settings rust-tools will provide to lspconfig during init.
|
||||||
|
-- We merge the necessary settings from nvim-lsp-installer (server:get_default_options())
|
||||||
|
-- with the user's own settings (opts).
|
||||||
|
server = vim.tbl_deep_extend("force", server:get_default_options(), opts),
|
||||||
|
}
|
||||||
|
server:attach_buffers()
|
||||||
|
-- Only if standalone support is needed
|
||||||
|
require("rust-tools").start_standalone_if_required()
|
||||||
|
else
|
||||||
|
server:setup(opts)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- Use an on_attach function to only map the following keys
|
|
||||||
-- after the language server attaches to the current buffer
|
|
||||||
local on_attach = function()
|
local on_attach = function()
|
||||||
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
||||||
local function set_option(...) vim.api.nvim_set_option(...) end
|
local function set_option(...) vim.api.nvim_set_option(...) end
|
||||||
|
@ -24,101 +68,11 @@ local on_attach = function()
|
||||||
set_keymap('', ';lt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
set_keymap('', ';lt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||||
set_keymap('', ';lr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
set_keymap('', ';lr', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||||
set_keymap('', ';la', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
set_keymap('', ';la', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||||
set_keymap('', ';lc', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
set_keymap('', ';le', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||||
set_keymap('', ';lo', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
set_keymap('', ';lo', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||||
set_keymap('', ';ln', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
set_keymap('', ';ln', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||||
set_keymap('', ';lp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
set_keymap('', ';lp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||||
set_keymap('', ';lm', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
set_keymap('', ';lm', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
|
||||||
-- map buffer local keybindings when the language server attaches
|
|
||||||
-- the packages for these servers are: pyright, rust-analyzer, texlab, and lua-language-server, deno, den
|
|
||||||
local servers = { 'pyright', 'texlab', 'denols'}
|
|
||||||
for _, lsp in ipairs(servers) do
|
|
||||||
nvim_lsp[lsp].setup {
|
|
||||||
flags = {
|
|
||||||
debounce_text_changes = 150,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
--deno typescript configuration
|
|
||||||
vim.g.markdown_fenced_languages = {
|
|
||||||
"ts=typescript"
|
|
||||||
}
|
|
||||||
|
|
||||||
--angular configuration. To install LS, $ npm install -g @angular/language-server
|
|
||||||
local project_library_path = "/path/to/project/lib"
|
|
||||||
local cmd = {"ngserver", "--stdio", "--tsProbeLocations", project_library_path , "--ngProbeLocations", project_library_path}
|
|
||||||
|
|
||||||
require'lspconfig'.angularls.setup{
|
|
||||||
cmd = cmd,
|
|
||||||
on_new_config = function(new_config,new_root_dir)
|
|
||||||
new_config.cmd = cmd
|
|
||||||
end,
|
|
||||||
}
|
|
||||||
|
|
||||||
--rust configuration
|
|
||||||
local rustOpts = {
|
|
||||||
tools = { -- rust-tools options
|
|
||||||
autoSetHints = true,
|
|
||||||
hover_with_actions = true,
|
|
||||||
inlay_hints = {
|
|
||||||
show_parameter_hints = false,
|
|
||||||
parameter_hints_prefix = "",
|
|
||||||
other_hints_prefix = "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
-- all the opts to send to nvim-lspconfig
|
|
||||||
-- these override the defaults set by rust-tools.nvim
|
|
||||||
-- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer
|
|
||||||
server = {
|
|
||||||
-- on_attach is a callback called when the language server attachs to the buffer
|
|
||||||
-- on_attach = on_attach,
|
|
||||||
settings = {
|
|
||||||
-- to enable rust-analyzer settings visit:
|
|
||||||
-- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc
|
|
||||||
["rust-analyzer"] = {
|
|
||||||
-- enable clippy on save
|
|
||||||
checkOnSave = {
|
|
||||||
command = "clippy"
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
require('rust-tools').setup(rustOpts)
|
|
||||||
|
|
||||||
--lua-language-server needs seperate config.
|
|
||||||
local runtime_path = vim.split(package.path, ';')
|
|
||||||
table.insert(runtime_path, "lua/?.lua")
|
|
||||||
table.insert(runtime_path, "lua/?/init.lua")
|
|
||||||
require'lspconfig'.sumneko_lua.setup {
|
|
||||||
settings = {
|
|
||||||
Lua = {
|
|
||||||
runtime = {
|
|
||||||
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
||||||
version = 'LuaJIT',
|
|
||||||
-- Setup your lua path
|
|
||||||
path = runtime_path,
|
|
||||||
},
|
|
||||||
diagnostics = {
|
|
||||||
-- Get the language server to recognize the `vim` global
|
|
||||||
globals = {'vim'},
|
|
||||||
},
|
|
||||||
workspace = {
|
|
||||||
-- Make the server aware of Neovim runtime files
|
|
||||||
library = vim.api.nvim_get_runtime_file("", true),
|
|
||||||
},
|
|
||||||
-- Do not send telemetry data containing a randomized but unique identifier
|
|
||||||
telemetry = {
|
|
||||||
enable = false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
on_attach()
|
on_attach()
|
||||||
|
install_servers()
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
--configure nvim-cmp for use with lsp and luasnip.
|
--configure nvim-cmp for use with lsp and luasnip.
|
||||||
|
|
||||||
|
|
||||||
-- Add additional capabilities supported by nvim-cmp
|
-- Add additional capabilities supported by nvim-cmp
|
||||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||||
|
@ -10,7 +9,7 @@ local luasnip = require 'luasnip'
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require('lspconfig')
|
||||||
|
|
||||||
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
-- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||||
local servers = {'texlab', 'rust_analyzer', 'pyright', 'denols'}
|
local servers = {'texlab', 'rust_analyzer', 'pyright'}
|
||||||
for _, lsp in ipairs(servers) do
|
for _, lsp in ipairs(servers) do
|
||||||
lspconfig[lsp].setup {
|
lspconfig[lsp].setup {
|
||||||
-- on_attach = my_custom_on_attach,
|
-- on_attach = my_custom_on_attach,
|
||||||
|
@ -61,7 +60,29 @@ cmp.setup {
|
||||||
},
|
},
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'path' },
|
||||||
{ name = 'luasnip' },
|
{ name = 'luasnip' },
|
||||||
{ name = 'buffer' }
|
{ name = 'buffer' },
|
||||||
|
{ name = 'dictionary' },
|
||||||
|
{ name = 'digraphs' },
|
||||||
|
{ name = 'spell' },
|
||||||
|
{ name = 'nvim_lsp_signature_help' },
|
||||||
|
{ name = 'emoji' },
|
||||||
|
{ name = 'latex_symbols' },
|
||||||
|
{ name = 'treesitter' },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmp.setup.cmdline(':', {
|
||||||
|
sources = {
|
||||||
|
{ name = 'cmdline' }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
cmp.setup.cmdline('/', {
|
||||||
|
sources = cmp.config.sources({
|
||||||
|
{ name = 'nvim_lsp_document_symbol' }
|
||||||
|
}, {
|
||||||
|
{ name = 'buffer' }
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
|
@ -20,17 +20,29 @@ return require('packer').startup(function(use)
|
||||||
indent={enable=true},
|
indent={enable=true},
|
||||||
incremental_selection={enable=true}
|
incremental_selection={enable=true}
|
||||||
}end,
|
}end,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use 'neovim/nvim-lspconfig'
|
use {
|
||||||
|
'neovim/nvim-lspconfig',
|
||||||
|
'williamboman/nvim-lsp-installer',
|
||||||
|
}
|
||||||
|
|
||||||
use {'hrsh7th/nvim-cmp',
|
use {'hrsh7th/nvim-cmp',
|
||||||
requires = {
|
requires = {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
'saadparwaiz1/cmp_luasnip',
|
'saadparwaiz1/cmp_luasnip',
|
||||||
'L3MON4D3/LuaSnip'
|
'hrsh7th/cmp-buffer',
|
||||||
|
'hrsh7th/cmp-path',
|
||||||
|
'hrsh7th/cmp-cmdline',
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
'f3fora/cmp-spell',
|
||||||
|
'dmitmel/cmp-digraphs',
|
||||||
|
'hrsh7th/cmp-nvim-lsp-signature-help',
|
||||||
|
'kdheepak/cmp-latex-symbols',
|
||||||
|
'hrsh7th/cmp-emoji',
|
||||||
|
'ray-x/cmp-treesitter',
|
||||||
|
'uga-rosa/cmp-dictionary',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue