add more lsp servers for nvim
This commit is contained in:
parent
a54e94bbb0
commit
79c002015c
8 changed files with 470 additions and 79 deletions
|
|
@ -14,6 +14,12 @@ require'lspconfig'.jdtls.setup {}
|
|||
require'lspconfig'.sumneko_lua.setup {}
|
||||
require'lspconfig'.gopls.setup {}
|
||||
require'lspconfig'.jsonls.setup {}
|
||||
require'lspconfig'.cssls.setup {}
|
||||
require'lspconfig'.csharp_ls.setup {}
|
||||
require'lspconfig'.tsserver.setup {}
|
||||
require'lspconfig'.sqls.setup {}
|
||||
require'lspconfig'.rust_analyzer.setup {}
|
||||
require'lspconfig'.bashls.setup {}
|
||||
|
||||
|
||||
require("nvim-lsp-installer").setup({
|
||||
|
|
@ -34,7 +40,7 @@ if not status_ok2 then
|
|||
end
|
||||
|
||||
local lspconfig = require("lspconfig")
|
||||
local servers = {"jdtls" , "sumneko_lua" , "texlab", "pyright" , "eslint" , "html" }
|
||||
local servers = {"jdtls" , "sumneko_lua" , "texlab", "pyright" , "eslint" , "html" , "cssls" , "rust_analyzer" , "bashls" , "csharp_ls" , "sqls" }
|
||||
|
||||
lsp_installer.setup {
|
||||
ensure_installed = servers
|
||||
|
|
|
|||
37
nvim/lua/settings/lsp_config/bashls.lua
Normal file
37
nvim/lua/settings/lsp_config/bashls.lua
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
local bin_name = 'bash-language-server'
|
||||
local cmd = { bin_name, 'start' }
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
cmd = { 'cmd.exe', '/C', bin_name, 'start' }
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = cmd,
|
||||
cmd_env = {
|
||||
-- Prevent recursive scanning which will cause issues when opening a file
|
||||
-- directly in the home directory (e.g. ~/foo.sh).
|
||||
--
|
||||
-- Default upstream pattern is "**/*@(.sh|.inc|.bash|.command)".
|
||||
GLOB_PATTERN = vim.env.GLOB_PATTERN or '*@(.sh|.inc|.bash|.command)',
|
||||
},
|
||||
filetypes = { 'sh' },
|
||||
root_dir = util.find_git_ancestor,
|
||||
single_file_support = true,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/mads-hartmann/bash-language-server
|
||||
`bash-language-server` can be installed via `npm`:
|
||||
```sh
|
||||
npm i -g bash-language-server
|
||||
```
|
||||
Language server for bash, written using tree sitter in typescript.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[util.find_git_ancestor]],
|
||||
},
|
||||
},
|
||||
}
|
||||
20
nvim/lua/settings/lsp_config/csharp_ls.lua
Normal file
20
nvim/lua/settings/lsp_config/csharp_ls.lua
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = { 'csharp-ls' },
|
||||
root_dir = util.root_pattern('*.sln', '*.csproj', '*.fsproj', '.git'),
|
||||
filetypes = { 'cs' },
|
||||
init_options = {
|
||||
AutomaticWorkspaceInit = true,
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/razzmatazz/csharp-language-server
|
||||
Language Server for C#.
|
||||
csharp-ls requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
|
||||
The preferred way to install csharp-ls is with `dotnet tool install --global csharp-ls`.
|
||||
]],
|
||||
},
|
||||
}
|
||||
43
nvim/lua/settings/lsp_config/cssls.lua
Normal file
43
nvim/lua/settings/lsp_config/cssls.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
local bin_name = 'vscode-css-language-server'
|
||||
local cmd = { bin_name, '--stdio' }
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = cmd,
|
||||
filetypes = { 'css', 'scss', 'less' },
|
||||
root_dir = util.root_pattern('package.json', '.git'),
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
css = { validate = true },
|
||||
scss = { validate = true },
|
||||
less = { validate = true },
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
`css-languageserver` can be installed via `npm`:
|
||||
```sh
|
||||
npm i -g vscode-langservers-extracted
|
||||
```
|
||||
Neovim does not currently include built-in snippets. `vscode-css-language-server` only provides completions when snippet support is enabled. To enable completion, install a snippet plugin and add the following override to your language client capabilities during setup.
|
||||
```lua
|
||||
--Enable (broadcasting) snippet capability for completion
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||
require'lspconfig'.cssls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("package.json", ".git") or bufdir]],
|
||||
},
|
||||
},
|
||||
}
|
||||
77
nvim/lua/settings/lsp_config/rust_analyzer.lua
Normal file
77
nvim/lua/settings/lsp_config/rust_analyzer.lua
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
local function reload_workspace(bufnr)
|
||||
bufnr = util.validate_bufnr(bufnr)
|
||||
vim.lsp.buf_request(bufnr, 'rust-analyzer/reloadWorkspace', nil, function(err)
|
||||
if err then
|
||||
error(tostring(err))
|
||||
end
|
||||
vim.notify 'Cargo workspace reloaded'
|
||||
end)
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = { 'rust-analyzer' },
|
||||
filetypes = { 'rust' },
|
||||
root_dir = function(fname)
|
||||
local cargo_crate_dir = util.root_pattern 'Cargo.toml'(fname)
|
||||
local cmd = { 'cargo', 'metadata', '--no-deps', '--format-version', '1' }
|
||||
if cargo_crate_dir ~= nil then
|
||||
cmd[#cmd + 1] = '--manifest-path'
|
||||
cmd[#cmd + 1] = util.path.join(cargo_crate_dir, 'Cargo.toml')
|
||||
end
|
||||
local cargo_metadata = ''
|
||||
local cargo_metadata_err = ''
|
||||
local cm = vim.fn.jobstart(cmd, {
|
||||
on_stdout = function(_, d, _)
|
||||
cargo_metadata = table.concat(d, '\n')
|
||||
end,
|
||||
on_stderr = function(_, d, _)
|
||||
cargo_metadata_err = table.concat(d, '\n')
|
||||
end,
|
||||
stdout_buffered = true,
|
||||
stderr_buffered = true,
|
||||
})
|
||||
if cm > 0 then
|
||||
cm = vim.fn.jobwait({ cm })[1]
|
||||
else
|
||||
cm = -1
|
||||
end
|
||||
local cargo_workspace_dir = nil
|
||||
if cm == 0 then
|
||||
cargo_workspace_dir = vim.json.decode(cargo_metadata)['workspace_root']
|
||||
else
|
||||
vim.notify(
|
||||
string.format('[lspconfig] cmd (%q) failed:\n%s', table.concat(cmd, ' '), cargo_metadata_err),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
end
|
||||
return util.path.sanitize(cargo_workspace_dir)
|
||||
or cargo_crate_dir
|
||||
or util.root_pattern 'rust-project.json'(fname)
|
||||
or util.find_git_ancestor(fname)
|
||||
end,
|
||||
settings = {
|
||||
['rust-analyzer'] = {},
|
||||
},
|
||||
},
|
||||
commands = {
|
||||
CargoReload = {
|
||||
function()
|
||||
reload_workspace(0)
|
||||
end,
|
||||
description = 'Reload current cargo workspace',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/rust-analyzer/rust-analyzer
|
||||
rust-analyzer (aka rls 2.0), a language server for Rust
|
||||
See [docs](https://github.com/rust-analyzer/rust-analyzer/tree/master/docs/user#settings) for extra settings.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("Cargo.toml", "rust-project.json")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
23
nvim/lua/settings/lsp_config/sqls.lua
Normal file
23
nvim/lua/settings/lsp_config/sqls.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
cmd = { 'sqls' },
|
||||
filetypes = { 'sql', 'mysql' },
|
||||
root_dir = util.root_pattern 'config.yml',
|
||||
single_file_support = true,
|
||||
settings = {},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/lighttiger2505/sqls
|
||||
```lua
|
||||
require'lspconfig'.sqls.setup{
|
||||
cmd = {"path/to/command", "-config", "path/to/config.yml"};
|
||||
...
|
||||
}
|
||||
```
|
||||
Sqls can be installed via `go get github.com/lighttiger2505/sqls`. Instructions for compiling Sqls from the source can be found at [lighttiger2505/sqls](https://github.com/lighttiger2505/sqls).
|
||||
]],
|
||||
},
|
||||
}
|
||||
56
nvim/lua/settings/lsp_config/tsserver.lua
Normal file
56
nvim/lua/settings/lsp_config/tsserver.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
local util = require 'lspconfig.util'
|
||||
|
||||
local bin_name = 'typescript-language-server'
|
||||
local cmd = { bin_name, '--stdio' }
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
cmd = { 'cmd.exe', '/C', bin_name, '--stdio' }
|
||||
end
|
||||
|
||||
return {
|
||||
default_config = {
|
||||
init_options = { hostInfo = 'neovim' },
|
||||
cmd = cmd,
|
||||
filetypes = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
},
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern 'tsconfig.json'(fname)
|
||||
or util.root_pattern('package.json', 'jsconfig.json', '.git')(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/theia-ide/typescript-language-server
|
||||
`typescript-language-server` depends on `typescript`. Both packages can be installed via `npm`:
|
||||
```sh
|
||||
npm install -g typescript typescript-language-server
|
||||
```
|
||||
To configure typescript language server, add a
|
||||
[`tsconfig.json`](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) or
|
||||
[`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) to the root of your
|
||||
project.
|
||||
Here's an example that disables type checking in JavaScript files.
|
||||
```json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"checkJs": false
|
||||
},
|
||||
"exclude": [
|
||||
"node_modules"
|
||||
]
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("package.json", "tsconfig.json", "jsconfig.json", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -22,20 +22,133 @@ vim.api.nvim_create_autocmd("BufEnter", {
|
|||
end
|
||||
})
|
||||
|
||||
nvim_tree.setup {
|
||||
disable_netrw = true,
|
||||
hijack_netrw = true,
|
||||
open_on_setup = false,
|
||||
ignore_ft_on_setup = {
|
||||
"startify",
|
||||
"dashboard",
|
||||
"alpha",
|
||||
},
|
||||
open_on_tab = false,
|
||||
|
||||
nvim_tree.setup { -- BEGIN_DEFAULT_OPTS
|
||||
auto_reload_on_write = true,
|
||||
create_in_closed_folder = false,
|
||||
disable_netrw = false,
|
||||
hijack_cursor = false,
|
||||
update_cwd = true,
|
||||
diagnostics = {
|
||||
hijack_netrw = true,
|
||||
hijack_unnamed_buffer_when_opening = false,
|
||||
ignore_buffer_on_setup = false,
|
||||
open_on_setup = true,
|
||||
open_on_setup_file = true,
|
||||
open_on_tab = true,
|
||||
ignore_buf_on_tab_change = {},
|
||||
sort_by = "name",
|
||||
root_dirs = {},
|
||||
prefer_startup_root = false,
|
||||
sync_root_with_cwd = false,
|
||||
reload_on_bufenter = false,
|
||||
respect_buf_cwd = false,
|
||||
on_attach = "disable", -- function(bufnr). If nil, will use the deprecated mapping strategy
|
||||
remove_keymaps = false, -- boolean (disable totally or not) or list of key (lhs)
|
||||
view = {
|
||||
adaptive_size = false,
|
||||
centralize_selection = false,
|
||||
width = 30,
|
||||
height = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
preserve_window_proportions = false,
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
signcolumn = "yes",
|
||||
-- @deprecated
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {
|
||||
-- user mappings go here
|
||||
},
|
||||
},
|
||||
float = {
|
||||
enable = false,
|
||||
open_win_config = {
|
||||
relative = "editor",
|
||||
border = "rounded",
|
||||
width = 30,
|
||||
height = 30,
|
||||
row = 1,
|
||||
col = 1,
|
||||
},
|
||||
},
|
||||
},
|
||||
renderer = {
|
||||
add_trailing = false,
|
||||
group_empty = false,
|
||||
highlight_git = false,
|
||||
full_name = false,
|
||||
highlight_opened_files = "none",
|
||||
root_folder_modifier = ":~",
|
||||
indent_width = 2,
|
||||
indent_markers = {
|
||||
enable = false,
|
||||
inline_arrows = true,
|
||||
icons = {
|
||||
corner = "└",
|
||||
edge = "│",
|
||||
item = "│",
|
||||
bottom = "─",
|
||||
none = " ",
|
||||
},
|
||||
},
|
||||
icons = {
|
||||
webdev_colors = true,
|
||||
git_placement = "before",
|
||||
padding = " ",
|
||||
symlink_arrow = " ➛ ",
|
||||
show = {
|
||||
file = true,
|
||||
folder = true,
|
||||
folder_arrow = true,
|
||||
git = true,
|
||||
},
|
||||
glyphs = {
|
||||
default = "",
|
||||
symlink = "",
|
||||
bookmark = "",
|
||||
folder = {
|
||||
arrow_closed = "",
|
||||
arrow_open = "",
|
||||
default = "",
|
||||
open = "",
|
||||
empty = "",
|
||||
empty_open = "",
|
||||
symlink = "",
|
||||
symlink_open = "",
|
||||
},
|
||||
git = {
|
||||
unstaged = "✗",
|
||||
staged = "✓",
|
||||
unmerged = "",
|
||||
renamed = "➜",
|
||||
untracked = "★",
|
||||
deleted = "",
|
||||
ignored = "◌",
|
||||
},
|
||||
},
|
||||
},
|
||||
special_files = { "cargo.toml", "makefile", "readme.md", "readme.md" },
|
||||
symlink_destination = true,
|
||||
},
|
||||
hijack_directories = {
|
||||
enable = true,
|
||||
auto_open = true,
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = false,
|
||||
update_root = false,
|
||||
ignore_list = {},
|
||||
},
|
||||
ignore_ft_on_setup = {},
|
||||
system_open = {
|
||||
cmd = "",
|
||||
args = {},
|
||||
},
|
||||
diagnostics = {
|
||||
enable = false,
|
||||
show_on_dirs = false,
|
||||
debounce_delay = 50,
|
||||
icons = {
|
||||
hint = "",
|
||||
info = "",
|
||||
|
|
@ -43,61 +156,77 @@ nvim_tree.setup {
|
|||
error = "",
|
||||
},
|
||||
},
|
||||
update_focused_file = {
|
||||
enable = true,
|
||||
update_cwd = true,
|
||||
ignore_list = {},
|
||||
},
|
||||
system_open = {
|
||||
cmd = nil,
|
||||
args = {},
|
||||
},
|
||||
filters = {
|
||||
dotfiles = false,
|
||||
custom = {},
|
||||
exclude = {},
|
||||
},
|
||||
filesystem_watchers = {
|
||||
enable = true,
|
||||
debounce_delay = 50,
|
||||
},
|
||||
git = {
|
||||
enable = true,
|
||||
ignore = true,
|
||||
timeout = 500,
|
||||
},
|
||||
view = {
|
||||
width = 30,
|
||||
height = 30,
|
||||
hide_root_folder = false,
|
||||
side = "left",
|
||||
mappings = {
|
||||
custom_only = false,
|
||||
list = {
|
||||
{ key = { "l", "<CR>", "o" }, cb = tree_cb "edit" },
|
||||
{ key = "h", cb = tree_cb "close_node" },
|
||||
{ key = "v", cb = tree_cb "vsplit" },
|
||||
},
|
||||
},
|
||||
number = false,
|
||||
relativenumber = false,
|
||||
},
|
||||
trash = {
|
||||
cmd = "trash",
|
||||
require_confirm = true,
|
||||
show_on_dirs = true,
|
||||
timeout = 400,
|
||||
},
|
||||
actions = {
|
||||
use_system_clipboard = true,
|
||||
change_dir = {
|
||||
enable = true,
|
||||
global = false,
|
||||
restrict_above_cwd = false,
|
||||
},
|
||||
expand_all = {
|
||||
max_folder_discovery = 300,
|
||||
exclude = {},
|
||||
},
|
||||
file_popup = {
|
||||
open_win_config = {
|
||||
col = 1,
|
||||
row = 1,
|
||||
relative = "cursor",
|
||||
border = "shadow",
|
||||
style = "minimal",
|
||||
},
|
||||
},
|
||||
open_file = {
|
||||
quit_on_open = true,
|
||||
quit_on_open = false,
|
||||
resize_window = true,
|
||||
window_picker = {
|
||||
enable = true,
|
||||
chars = "abcdefghijklmnopqrstuvwxyz1234567890",
|
||||
exclude = {
|
||||
filetype = { "notify", "packer", "qf", "diff", "fugitive", "fugitiveblame" },
|
||||
buftype = { "nofile", "terminal", "help" },
|
||||
},
|
||||
},
|
||||
},
|
||||
remove_file = {
|
||||
close_window = true,
|
||||
},
|
||||
},
|
||||
trash = {
|
||||
cmd = "gio trash",
|
||||
require_confirm = true,
|
||||
},
|
||||
live_filter = {
|
||||
prefix = "[FILTER]: ",
|
||||
always_show_folders = true,
|
||||
},
|
||||
log = {
|
||||
enable = false,
|
||||
truncate = false,
|
||||
types = {
|
||||
all = false,
|
||||
config = false,
|
||||
copy_paste = false,
|
||||
dev = false,
|
||||
diagnostics = false,
|
||||
git = false,
|
||||
profile = false,
|
||||
watcher = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- unknown options as of 22.05
|
||||
--
|
||||
-- update_to_buf_dir = {
|
||||
-- enable = true,
|
||||
-- auto_open = true,
|
||||
-- },
|
||||
-- auto_resize = true,
|
||||
-- git_hl = 1,
|
||||
-- root_folder_modifier = ":t",
|
||||
|
||||
}
|
||||
} -- END_DEFAULT_OPTS
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue