mirror of
https://github.com/LunarVim/LunarVim.git
synced 2025-07-30 15:44:37 +02:00
new language servers and smart document highlighting
This commit is contained in:
parent
3266955359
commit
6ed2437edb
15 changed files with 68 additions and 9 deletions
13
README.md
13
README.md
|
@ -4,7 +4,7 @@ If you are looking for my old configs checkout the two snapshot branches on this
|
||||||
|
|
||||||
## Install in one command
|
## Install in one command
|
||||||
|
|
||||||
**WARNING** Still very experimental will not woek without some configuation
|
**WARNING** Still very experimental will not work without some configuation
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bash <(curl -s https://raw.githubusercontent.com/ChristianChiarulli/nvcode/master/utils/installer/install-nv-code.sh)
|
bash <(curl -s https://raw.githubusercontent.com/ChristianChiarulli/nvcode/master/utils/installer/install-nv-code.sh)
|
||||||
|
@ -42,14 +42,22 @@ or if you are using this config alongside your own:
|
||||||
$HOME/.config/nvim/lua/nv-vscode/init.vim
|
$HOME/.config/nvim/lua/nv-vscode/init.vim
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## efm server is slow on close
|
||||||
|
|
||||||
|
Install the latest with:
|
||||||
|
|
||||||
|
```
|
||||||
|
go get github.com/mattn/efm-langserver@HEAD
|
||||||
|
```
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
**HIGH PRIORITY**
|
**HIGH PRIORITY**
|
||||||
- formatting using efm server for python
|
- formatting using efm server for python
|
||||||
- formatting using efm server for lua
|
|
||||||
- formatting using efm server for prettier/eslint
|
- formatting using efm server for prettier/eslint
|
||||||
- learn what opt is
|
- learn what opt is
|
||||||
- better install script
|
- better install script
|
||||||
|
- learn nvim-dap in depth
|
||||||
- snippet support
|
- snippet support
|
||||||
|
|
||||||
**LOW PRIORITY**
|
**LOW PRIORITY**
|
||||||
|
@ -67,4 +75,3 @@ $HOME/.config/nvim/lua/nv-vscode/init.vim
|
||||||
- get logo
|
- get logo
|
||||||
- configure neogit
|
- configure neogit
|
||||||
- toggle virtual text diagnostics
|
- toggle virtual text diagnostics
|
||||||
- learn nvim-dap in depth
|
|
||||||
|
|
5
init.lua
5
init.lua
|
@ -46,5 +46,10 @@ else
|
||||||
require('lsp.python-ls')
|
require('lsp.python-ls')
|
||||||
require('lsp.json-ls')
|
require('lsp.json-ls')
|
||||||
require('lsp.yaml-ls')
|
require('lsp.yaml-ls')
|
||||||
|
require('lsp.vim-ls')
|
||||||
|
require('lsp.graphql-ls')
|
||||||
|
require('lsp.css-ls')
|
||||||
|
require('lsp.docker-ls')
|
||||||
|
require('lsp.html-ls')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
-- npm i -g bash-language-server
|
-- npm i -g bash-language-server
|
||||||
require'lspconfig'.bashls.setup{}
|
require'lspconfig'.bashls.setup {on_attach = require'lsp'.common_on_attach}
|
||||||
|
|
2
lua/lsp/css-ls.lua
Normal file
2
lua/lsp/css-ls.lua
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
-- npm install -g vscode-css-languageserver-bin
|
||||||
|
require'lspconfig'.cssls.setup {on_attach = require'lsp'.common_on_attach}
|
2
lua/lsp/docker-ls.lua
Normal file
2
lua/lsp/docker-ls.lua
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
-- npm install -g dockerfile-language-server-nodejs
|
||||||
|
require'lspconfig'.dockerls.setup {on_attach = require'lsp'.common_on_attach}
|
2
lua/lsp/graphql-ls.lua
Normal file
2
lua/lsp/graphql-ls.lua
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
-- npm install -g graphql-language-service-cli
|
||||||
|
require'lspconfig'.graphql.setup {on_attach = require'lsp'.common_on_attach}
|
8
lua/lsp/html-ls.lua
Normal file
8
lua/lsp/html-ls.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
-- npm install -g vscode-html-languageserver-bin
|
||||||
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||||
|
capabilities.textDocument.completion.completionItem.snippetSupport = true
|
||||||
|
|
||||||
|
require'lspconfig'.html.setup {
|
||||||
|
on_attach = require'lsp'.common_on_attach,
|
||||||
|
capabilities = capabilities
|
||||||
|
}
|
|
@ -30,8 +30,7 @@ vim.cmd('nnoremap <silent> K :Lspsaga hover_doc<CR>')
|
||||||
vim.cmd('nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>')
|
vim.cmd('nnoremap <silent> <C-p> :Lspsaga diagnostic_jump_prev<CR>')
|
||||||
vim.cmd('nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>')
|
vim.cmd('nnoremap <silent> <C-n> :Lspsaga diagnostic_jump_next<CR>')
|
||||||
-- scroll down hover doc or scroll in definition preview
|
-- scroll down hover doc or scroll in definition preview
|
||||||
vim.cmd(
|
vim.cmd('nnoremap <silent> <C-f> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(1)<CR>')
|
||||||
'nnoremap <silent> <C-f> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(1)<CR>')
|
|
||||||
-- scroll up hover doc
|
-- scroll up hover doc
|
||||||
vim.cmd(
|
vim.cmd(
|
||||||
'nnoremap <silent> <C-b> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)<CR>')
|
'nnoremap <silent> <C-b> <cmd>lua require(\'lspsaga.action\').smart_scroll_with_saga(-1)<CR>')
|
||||||
|
@ -42,3 +41,28 @@ autocmd BufWritePre *.jsx lua vim.lsp.buf.formatting_sync(nil, 100)
|
||||||
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]
|
autocmd BufWritePre *.lua lua vim.lsp.buf.formatting_sync(nil, 100) ]]
|
||||||
-- Java
|
-- Java
|
||||||
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
|
-- autocmd FileType java nnoremap ca <Cmd>lua require('jdtls').code_action()<CR>
|
||||||
|
|
||||||
|
local lsp_config = {}
|
||||||
|
|
||||||
|
function lsp_config.common_on_attach(client, bufnr)
|
||||||
|
|
||||||
|
-- Set autocommands conditional on server_capabilities
|
||||||
|
if client.resolved_capabilities.document_highlight then
|
||||||
|
vim.api.nvim_exec([[
|
||||||
|
hi LspReferenceRead cterm=bold ctermbg=red guibg=#464646
|
||||||
|
hi LspReferenceText cterm=bold ctermbg=red guibg=#464646
|
||||||
|
hi LspReferenceWrite cterm=bold ctermbg=red guibg=#464646
|
||||||
|
augroup lsp_document_highlight
|
||||||
|
autocmd! * <buffer>
|
||||||
|
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
|
||||||
|
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
|
||||||
|
augroup END
|
||||||
|
]], false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Use a loop to conveniently both setup defined servers
|
||||||
|
-- and map buffer local keybindings when the language server attaches
|
||||||
|
-- local servers = {"pyright", "tsserver"}
|
||||||
|
-- for _, lsp in ipairs(servers) do nvim_lsp[lsp].setup {on_attach = on_attach} end
|
||||||
|
return lsp_config
|
||||||
|
|
|
@ -13,6 +13,7 @@ else
|
||||||
print("Unsupported system")
|
print("Unsupported system")
|
||||||
end
|
end
|
||||||
require('jdtls').start_or_attach({
|
require('jdtls').start_or_attach({
|
||||||
|
on_attach = require'lsp'.common_on_attach,
|
||||||
cmd = {JAVA_LS_EXECUTABLE},
|
cmd = {JAVA_LS_EXECUTABLE},
|
||||||
root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})
|
root_dir = require('jdtls.setup').find_root({'gradle.build', 'pom.xml'})
|
||||||
})
|
})
|
||||||
|
|
|
@ -7,4 +7,4 @@
|
||||||
-- require'completion'.on_attach(client)
|
-- require'completion'.on_attach(client)
|
||||||
-- require'illuminate'.on_attach(client)
|
-- require'illuminate'.on_attach(client)
|
||||||
-- end
|
-- end
|
||||||
require'lspconfig'.tsserver.setup {}
|
require'lspconfig'.tsserver.setup {on_attach = require'lsp'.common_on_attach}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
-- npm install -g vscode-json-languageserver
|
-- npm install -g vscode-json-languageserver
|
||||||
require'lspconfig'.jsonls.setup {
|
require'lspconfig'.jsonls.setup {
|
||||||
|
on_attach = require'lsp'.common_on_attach,
|
||||||
commands = {
|
commands = {
|
||||||
Format = {
|
Format = {
|
||||||
function()
|
function()
|
||||||
|
|
|
@ -20,6 +20,7 @@ end
|
||||||
|
|
||||||
require'lspconfig'.sumneko_lua.setup {
|
require'lspconfig'.sumneko_lua.setup {
|
||||||
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
|
cmd = {sumneko_binary, "-E", sumneko_root_path .. "/main.lua"},
|
||||||
|
on_attach = require'lsp'.common_on_attach,
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
runtime = {
|
runtime = {
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
-- npm i -g pyright
|
-- npm i -g pyright
|
||||||
require'lspconfig'.pyright.setup{}
|
require'lspconfig'.pyright.setup{
|
||||||
|
on_attach = require'lsp'.common_on_attach,
|
||||||
|
}
|
||||||
|
|
2
lua/lsp/vim-ls.lua
Normal file
2
lua/lsp/vim-ls.lua
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
-- npm install -g vim-language-server
|
||||||
|
require'lspconfig'.vimls.setup {on_attach = require'lsp'.common_on_attach}
|
|
@ -1,2 +1,4 @@
|
||||||
-- npm install -g yaml-language-server
|
-- npm install -g yaml-language-server
|
||||||
require'lspconfig'.yamlls.setup{}
|
require'lspconfig'.yamlls.setup{
|
||||||
|
-- on_attach = require'lsp'.common_on_attach,
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue