mirror of
https://git.disroot.org/FollieHiyuki/dotfiles.git
synced 2024-11-24 16:28:22 -05:00
neovim: add scripts to install lsp servers
This commit is contained in:
parent
ef76692015
commit
1f973f3850
@ -70,6 +70,7 @@ function M.lsp_conf()
|
|||||||
-- Server configurations --
|
-- Server configurations --
|
||||||
---------------------------
|
---------------------------
|
||||||
-- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
|
-- https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md
|
||||||
|
local servers_path = vim.fn.stdpath('data') .. '/lsp'
|
||||||
|
|
||||||
-- C/C++
|
-- C/C++
|
||||||
lspconf.clangd.setup {
|
lspconf.clangd.setup {
|
||||||
@ -121,9 +122,9 @@ function M.lsp_conf()
|
|||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
cmd = {
|
cmd = {
|
||||||
vim.fn.stdpath('data') .. '/lsp/lua-language-server/bin/Linux/lua-language-server',
|
servers_path .. '/sumneko_lua/bin/Linux/lua-language-server',
|
||||||
'-E',
|
'-E', '-e', 'LANG=en',
|
||||||
vim.fn.stdpath('data') .. '/lsp/lua-language-server/main.lua'
|
servers_path .. '/sumneko_lua/main.lua'
|
||||||
},
|
},
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
@ -145,18 +146,41 @@ function M.lsp_conf()
|
|||||||
lspconf.gopls.setup {
|
lspconf.gopls.setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities,
|
capabilities = capabilities,
|
||||||
cmd = {'gopls', '--remote=auto'},
|
cmd = {servers_path .. '/gopls/gopls', '--remote=auto'},
|
||||||
init_options = {
|
init_options = {
|
||||||
usePlaceholders = true,
|
usePlaceholders = true,
|
||||||
completeUnimported = true
|
completeUnimported = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- Yaml
|
||||||
|
-- lspconf.yamlls.setup {
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- cmd = {servers_path .. '/yamlls/node_modules/.bin/yaml-language-server', '--stdio'},
|
||||||
|
-- settings = {
|
||||||
|
-- redhat = {telemetry = {enabled = false}},
|
||||||
|
-- yaml = {format = {bracketSpacing = true}}
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
|
||||||
|
-- Tailwind
|
||||||
|
-- lspconf.tailwindcss.setup {
|
||||||
|
-- on_attach = on_attach,
|
||||||
|
-- capabilities = capabilities,
|
||||||
|
-- cmd = {servers_path .. '/tailwindcss/node_modules/.bin/tailwindcss-language-server', '--stdio'},
|
||||||
|
-- settings = {
|
||||||
|
-- tailwindCSS = {
|
||||||
|
-- emmetCompletions = true
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
-- }
|
||||||
|
|
||||||
-- Emmet
|
-- Emmet
|
||||||
if not lspconf.emmet_ls then
|
if not lspconf.emmet_ls then
|
||||||
require('lspconfig/configs').emmet_ls = {
|
require('lspconfig/configs').emmet_ls = {
|
||||||
default_config = {
|
default_config = {
|
||||||
cmd = {'emmet-ls', '--stdio'},
|
cmd = {servers_path .. '/emmet_ls/node_modules/.bin/emmet-ls', '--stdio'},
|
||||||
filetypes = {'html', 'css'},
|
filetypes = {'html', 'css'},
|
||||||
root_dir = function(fname)
|
root_dir = function(fname)
|
||||||
return vim.loop.cwd()
|
return vim.loop.cwd()
|
||||||
@ -167,15 +191,32 @@ function M.lsp_conf()
|
|||||||
end
|
end
|
||||||
lspconf.emmet_ls.setup {capabilities = capabilities}
|
lspconf.emmet_ls.setup {capabilities = capabilities}
|
||||||
|
|
||||||
|
-- HTML
|
||||||
|
lspconf.html.setup {
|
||||||
|
on_attach = on_attach,
|
||||||
|
capabilities = capabilities,
|
||||||
|
cmd = {servers_path .. '/vscode/node_modules/.bin/vscode-html-language-server', '--stdio'},
|
||||||
|
filetypes = {'html', 'markdown'}
|
||||||
|
}
|
||||||
|
|
||||||
-- Others
|
-- Others
|
||||||
local servers = {
|
local servers = {
|
||||||
'dockerls', 'bashls', 'pyright', 'tsserver',
|
rust_analyzer = {'rust-analyzer'},
|
||||||
'html', 'jsonls', 'cmake', 'sqls', 'rust_analyzer'
|
sqls = {servers_path .. '/sqls/sqls'},
|
||||||
|
cmake = {servers_path .. '/cmake/venv/bin/cmake-language-server'},
|
||||||
|
bashls = {servers_path .. '/bashls/node_modules/.bin/bash-language-server', 'start'},
|
||||||
|
dockerls = {servers_path .. '/dockerls/node_modules/.bin/docker-langserver', '--stdio'},
|
||||||
|
jsonls = {servers_path .. '/vscode/node_modules/.bin/vscode-json-language-server', '--stdio'},
|
||||||
|
cssls = {servers_path .. '/vscode/node_modules/.bin/vscode-css-language-server', '--stdio'},
|
||||||
|
pyright = {servers_path .. '/pyright/node_modules/.bin/pyright-langserver', '--stdio'},
|
||||||
|
-- vimls = {servers_path .. '/vimls/node_modules/.bin/vim-language-server', '--stdio'},
|
||||||
|
tsserver = {servers_path .. '/tsserver/node_modules/.bin/typescript-language-server', '--stdio'}
|
||||||
}
|
}
|
||||||
for _, server in ipairs(servers) do
|
for server, _ in pairs(servers) do
|
||||||
lspconf[server].setup {
|
lspconf[server].setup {
|
||||||
on_attach = on_attach,
|
on_attach = on_attach,
|
||||||
capabilities = capabilities
|
capabilities = capabilities,
|
||||||
|
cmd = servers[server]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ return packer.startup(function(use)
|
|||||||
-- LSP --
|
-- LSP --
|
||||||
---------
|
---------
|
||||||
local lsp = require('modules.lsp')
|
local lsp = require('modules.lsp')
|
||||||
use { -- TODO: scripts to install/update lsp servers
|
use {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
event = 'BufReadPre',
|
event = 'BufReadPre',
|
||||||
wants = 'lsp_signature.nvim',
|
wants = 'lsp_signature.nvim',
|
||||||
@ -154,7 +154,7 @@ return packer.startup(function(use)
|
|||||||
}
|
}
|
||||||
use {
|
use {
|
||||||
'nanotee/sqls.nvim',
|
'nanotee/sqls.nvim',
|
||||||
ft = {'sql', 'mysql', 'plsql'},
|
ft = {'sql', 'mysql'},
|
||||||
wants = 'nvim-lspconfig',
|
wants = 'nvim-lspconfig',
|
||||||
config = lsp.sqls_conf
|
config = lsp.sqls_conf
|
||||||
}
|
}
|
||||||
|
32
home/.config/nvim/scripts/install
Executable file
32
home/.config/nvim/scripts/install
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# TODO: consider forking 'kabouzeid/nvim-lspinstall' or 'anott03/nvim-lspinstall'
|
||||||
|
# instead of running scripts
|
||||||
|
if [ "$#" -ne 1 ]; then
|
||||||
|
echo "Usage:"
|
||||||
|
printf " - %s server_name: install specified server\n" "$0"
|
||||||
|
printf " - %s -lsp: install all lsp servers\n" "$0"
|
||||||
|
printf " - %s -dap: install all dap servers\n" "$0"
|
||||||
|
printf " - %s -lint: install everything\n" "$0"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
nvim_script_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nvim/scripts
|
||||||
|
|
||||||
|
if [ "$1" = "-lsp" ]; then
|
||||||
|
find "${nvim_script_dir}/lsp" -type f -exec '{}' \;
|
||||||
|
elif [ "$1" = '-dap' ]; then
|
||||||
|
find "${nvim_script_dir}/dap" -type f -exec '{}' \;
|
||||||
|
elif [ "$1" = '-lint' ]; then
|
||||||
|
find "${nvim_script_dir}/lint" -type f -exec '{}' \;
|
||||||
|
elif [ "$1" = '-all' ]; then
|
||||||
|
find "${nvim_script_dir}" -mindepth 2 -type f -exec '{}' \;
|
||||||
|
else
|
||||||
|
# Each server should have an unique name
|
||||||
|
server_path=$(find "${nvim_script_dir}" -mindepth 2 -type f -name "$1" | head -n 1)
|
||||||
|
if [ -z "${server_path}" ]; then
|
||||||
|
echo "Incorrect server name."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
exec ${server_path}
|
||||||
|
fi
|
12
home/.config/nvim/scripts/lsp/bashls
Executable file
12
home/.config/nvim/scripts/lsp/bashls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/bashls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install bash-language-server@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
13
home/.config/nvim/scripts/lsp/cmake
Executable file
13
home/.config/nvim/scripts/lsp/cmake
Executable file
@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/cmake"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
python3 -m venv ${server_path}/venv
|
||||||
|
${server_path}/venv/bin/pip3 install -U pip
|
||||||
|
${server_path}/venv/bin/pip3 install -U cmake-language-server
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/dockerls
Executable file
12
home/.config/nvim/scripts/lsp/dockerls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/dockerls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install dockerfile-language-server-nodejs@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/emmet_ls
Executable file
12
home/.config/nvim/scripts/lsp/emmet_ls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/emmet_ls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install emmet-ls@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/gopls
Executable file
12
home/.config/nvim/scripts/lsp/gopls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/gopls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
GOPATH="${server_path}" GOBIN="${server_path}" go install golang.org/x/tools/gopls@latest
|
||||||
|
GOPATH="${server_path}" GOBIN="${server_path}" go clean -modcache
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/pyright
Executable file
12
home/.config/nvim/scripts/lsp/pyright
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/pyright"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install pyright@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/sqls
Executable file
12
home/.config/nvim/scripts/lsp/sqls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/sqls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
GOPATH="${server_path}" GOBIN="${server_path}" go install github.com/lighttiger2505/sqls@latest
|
||||||
|
GOPATH="${server_path}" GOBIN="${server_path}" go clean -modcache
|
||||||
|
|
||||||
|
cd ${current_path}
|
@ -1,17 +1,17 @@
|
|||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
|
|
||||||
current_path="$PWD"
|
current_path="$PWD"
|
||||||
luals_path="$HOME/.local/share/nvim/lsp/lua-language-server"
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/sumneko_lua"
|
||||||
|
|
||||||
# Clone / Update
|
# Clone / Update
|
||||||
if [ -d "$luals_path" ]; then
|
if [ -d "${server_path}" ]; then
|
||||||
cd $luals_path
|
cd ${server_path}
|
||||||
git pull --rebase
|
git pull --rebase
|
||||||
else
|
else
|
||||||
git clone https://github.com/sumneko/lua-language-server.git $luals_path
|
git clone https://github.com/sumneko/lua-language-server.git ${server_path}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd $luals_path
|
cd ${server_path}
|
||||||
git submodule update --init --recursive
|
git submodule update --init --recursive
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
@ -23,4 +23,4 @@ cd ../..
|
|||||||
# The build process automatically exports path to `~/.profile`
|
# The build process automatically exports path to `~/.profile`
|
||||||
rm -rf ~/.profile
|
rm -rf ~/.profile
|
||||||
|
|
||||||
cd $current_path
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/tailwindcss
Executable file
12
home/.config/nvim/scripts/lsp/tailwindcss
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/tailwindcss"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install @tailwindcss/language-server
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/tsserver
Executable file
12
home/.config/nvim/scripts/lsp/tsserver
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/tsserver"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install typescript@latest typescript-language-server@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/vimls
Executable file
12
home/.config/nvim/scripts/lsp/vimls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/vimls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && yarn init -y || true
|
||||||
|
yarn add vim-language-server@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/vscode
Executable file
12
home/.config/nvim/scripts/lsp/vscode
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/vscode"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && npm init -y --scope=lsp || true
|
||||||
|
npm install vscode-langservers-extracted@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
12
home/.config/nvim/scripts/lsp/yamlls
Executable file
12
home/.config/nvim/scripts/lsp/yamlls
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh -e
|
||||||
|
|
||||||
|
current_path="$PWD"
|
||||||
|
server_path="${XDG_DATA_HOME:-$HOME/.local/share}/nvim/lsp/yamlls"
|
||||||
|
|
||||||
|
[ ! -d "${server_path}" ] && mkdir -p "${server_path}"
|
||||||
|
cd ${server_path}
|
||||||
|
|
||||||
|
[ ! -f package.json ] && yarn init -y || true
|
||||||
|
yarn add yaml-language-server@latest
|
||||||
|
|
||||||
|
cd ${current_path}
|
Loading…
Reference in New Issue
Block a user