mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 10:40:03 +08:00
feat(lsp): add neovim-lsp (#4319)
This commit is contained in:
parent
516e0525e2
commit
da18ba0a45
@ -38,6 +38,8 @@ else
|
||||
let s:timeoutlen = &timeoutlen
|
||||
endif
|
||||
|
||||
let s:NVIM_VERSION = SpaceVim#api#import('neovim#version')
|
||||
|
||||
function! SpaceVim#layers#autocomplete#plugins() abort
|
||||
let plugins = [
|
||||
\ [g:_spacevim_root_dir . 'bundle/vim-snippets', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}],
|
||||
|
@ -501,6 +501,8 @@ function! SpaceVim#layers#core#statusline#get(...) abort
|
||||
return '%#SpaceVim_statusline_a# Git log popup %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'respones.idris'
|
||||
return '%#SpaceVim_statusline_a# Idris Response %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'markdown.lspdoc'
|
||||
return '%#SpaceVim_statusline_a# LSP hover info %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimWinDiskManager'
|
||||
return '%#SpaceVim_statusline_a# WinDisk %#SpaceVim_statusline_a_SpaceVim_statusline_b#' . s:lsep
|
||||
elseif &filetype ==# 'SpaceVimTodoManager'
|
||||
|
@ -57,18 +57,20 @@ function! SpaceVim#layers#lang#vim#plugins() abort
|
||||
\ ]
|
||||
call add(plugins,['tweekmonster/exception.vim', {'merged' : 0}])
|
||||
call add(plugins,['wsdjeg/vim-lookup', {'merged' : 0}])
|
||||
call add(plugins,['Shougo/neco-vim', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}])
|
||||
if g:spacevim_autocomplete_method ==# 'asyncomplete'
|
||||
call add(plugins, ['prabirshrestha/asyncomplete-necovim.vim', {
|
||||
\ 'loadconf' : 1,
|
||||
\ 'merged' : 0,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'coc'
|
||||
call add(plugins, ['neoclide/coc-neco', {'merged' : 0}])
|
||||
elseif g:spacevim_autocomplete_method ==# 'completor'
|
||||
" call add(plugins, ['kyouryuukunn/completor-necovim', {'merged' : 0}])
|
||||
" This plugin has bug in neovim-qt win 7
|
||||
" https://github.com/maralla/completor.vim/issues/250
|
||||
if !SpaceVim#layers#lsp#check_server('vimls') && !SpaceVim#layers#lsp#check_filetype('vim')
|
||||
call add(plugins,['Shougo/neco-vim', { 'on_event' : 'InsertEnter', 'loadconf_before' : 1}])
|
||||
if g:spacevim_autocomplete_method ==# 'asyncomplete'
|
||||
call add(plugins, ['prabirshrestha/asyncomplete-necovim.vim', {
|
||||
\ 'loadconf' : 1,
|
||||
\ 'merged' : 0,
|
||||
\ }])
|
||||
elseif g:spacevim_autocomplete_method ==# 'coc'
|
||||
call add(plugins, ['neoclide/coc-neco', {'merged' : 0}])
|
||||
elseif g:spacevim_autocomplete_method ==# 'completor'
|
||||
" call add(plugins, ['kyouryuukunn/completor-necovim', {'merged' : 0}])
|
||||
" This plugin has bug in neovim-qt win 7
|
||||
" https://github.com/maralla/completor.vim/issues/250
|
||||
endif
|
||||
endif
|
||||
call add(plugins,['tweekmonster/helpful.vim', {'on_cmd': 'HelpfulVersion'}])
|
||||
return plugins
|
||||
@ -88,12 +90,12 @@ function! SpaceVim#layers#lang#vim#config() abort
|
||||
endfunction
|
||||
|
||||
function! s:on_exit(...) abort
|
||||
let data = get(a:000, 2)
|
||||
if data != 0
|
||||
call s:NOTI.notify('failed to generate doc!', 'WarningMsg')
|
||||
else
|
||||
call s:NOTI.notify('vim doc generated!', 'Normal')
|
||||
endif
|
||||
let data = get(a:000, 2)
|
||||
if data != 0
|
||||
call s:NOTI.notify('failed to generate doc!', 'WarningMsg')
|
||||
else
|
||||
call s:NOTI.notify('vim doc generated!', 'Normal')
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:generate_doc() abort
|
||||
@ -105,13 +107,13 @@ function! s:generate_doc() abort
|
||||
let dir = s:FILE.unify_path(addon_info, ':h')
|
||||
if executable('vimdoc') && !s:SYS.isWindows
|
||||
call s:JOB.start(['vimdoc', dir],
|
||||
\ {
|
||||
\ {
|
||||
\ 'on_exit' : function('s:on_exit'),
|
||||
\ }
|
||||
\ )
|
||||
elseif executable('python')
|
||||
call s:JOB.start(['python', '-m', 'vimdoc', dir],
|
||||
\ {
|
||||
\ {
|
||||
\ 'on_exit' : function('s:on_exit'),
|
||||
\ }
|
||||
\ )
|
||||
|
@ -6,25 +6,92 @@
|
||||
" License: GPLv3
|
||||
"=============================================================================
|
||||
|
||||
if exists('s:NVIM_VERSION')
|
||||
finish
|
||||
endif
|
||||
|
||||
""
|
||||
" @section language server protocol, layers-lsp
|
||||
" @parentsection layers
|
||||
" This layer provides language client support for SpaceVim.
|
||||
|
||||
let s:NVIM_VERSION = SpaceVim#api#import('neovim#version')
|
||||
let s:enabled_clients = []
|
||||
|
||||
function! SpaceVim#layers#lsp#health() abort
|
||||
call SpaceVim#layers#lsp#plugins()
|
||||
call SpaceVim#layers#lsp#config()
|
||||
return 1
|
||||
endfunction
|
||||
|
||||
|
||||
function! SpaceVim#layers#lsp#setup() abort
|
||||
lua << EOF
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, 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
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
-- local opts = { noremap=true, silent=true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
-- 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>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
-- buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
-- buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
-- buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
-- buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
end
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = require('spacevim').eval('s:enabled_clients')
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
EOF
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lsp#plugins() abort
|
||||
let plugins = []
|
||||
|
||||
if SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
|
||||
if (has('nvim-0.5.0') && s:NVIM_VERSION.is_release_version()) || has('nvim-0.6.0')
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/nvim-lspconfig', {'merged' : 0, 'loadconf' : 1}])
|
||||
if g:spacevim_autocomplete_method ==# 'deoplete'
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/deoplete-lsp', {'merged' : 0}])
|
||||
endif
|
||||
elseif SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
|
||||
" nop
|
||||
elseif has('nvim-0.4.3')
|
||||
" use neovim build-in lsp
|
||||
elseif has('nvim')
|
||||
call add(plugins, ['autozimu/LanguageClient-neovim',
|
||||
\ { 'merged': 0, 'if': has('python3'), 'build' : 'bash install.sh' }])
|
||||
call add(plugins, ['bfredl/nvim-lspmirror', {'merged' : 0}])
|
||||
call add(plugins, ['bfredl/nvim-lspext', {'merged' : 0}])
|
||||
call add(plugins, ['shougo/deoplete-lsp', {'merged' : 0}])
|
||||
else
|
||||
call add(plugins, ['prabirshrestha/async.vim', {'merged' : 0}])
|
||||
call add(plugins, ['prabirshrestha/vim-lsp', {'merged' : 0}])
|
||||
@ -34,37 +101,40 @@ function! SpaceVim#layers#lsp#plugins() abort
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lsp#config() abort
|
||||
for ft in s:enabled_fts
|
||||
call SpaceVim#lsp#reg_server(ft, s:lsp_servers[ft])
|
||||
endfor
|
||||
" SpaceVim/LanguageClient-neovim {{{
|
||||
let g:LanguageClient_diagnosticsDisplay = {
|
||||
\ 1: {
|
||||
\ 'name': 'Error',
|
||||
\ 'texthl': 'LanguageClientError',
|
||||
\ 'signText': g:spacevim_error_symbol,
|
||||
\ 'signTexthl': 'LanguageClientError',
|
||||
\ 'virtualTexthl': 'Error',
|
||||
\ },
|
||||
\ 2: {
|
||||
\ 'name': 'Warning',
|
||||
\ 'texthl': 'LanguageClientWarning',
|
||||
\ 'signText': g:spacevim_warning_symbol,
|
||||
\ 'signTexthl': 'LanguageClientWarningSign',
|
||||
\ 'virtualTexthl': 'Todo',
|
||||
\ },
|
||||
\ 3: {
|
||||
\ 'name': 'Information',
|
||||
\ 'texthl': 'LanguageClientInfo',
|
||||
\ 'signText': g:spacevim_info_symbol,
|
||||
\ 'signTexthl': 'LanguageClientInfoSign',
|
||||
\ 'virtualTexthl': 'Todo',
|
||||
\ },
|
||||
\ 4: {
|
||||
\ 'name': 'Hint',
|
||||
\ 'texthl': 'LanguageClientInfo',
|
||||
\ 'signText': g:spacevim_info_symbol,
|
||||
\ 'signTexthl': 'LanguageClientInfoSign',
|
||||
\ 'virtualTexthl': 'Todo',
|
||||
\ },
|
||||
\ }
|
||||
\ 'name': 'Error',
|
||||
\ 'texthl': 'LanguageClientError',
|
||||
\ 'signText': g:spacevim_error_symbol,
|
||||
\ 'signTexthl': 'LanguageClientError',
|
||||
\ 'virtualTexthl': 'Error',
|
||||
\ },
|
||||
\ 2: {
|
||||
\ 'name': 'Warning',
|
||||
\ 'texthl': 'LanguageClientWarning',
|
||||
\ 'signText': g:spacevim_warning_symbol,
|
||||
\ 'signTexthl': 'LanguageClientWarningSign',
|
||||
\ 'virtualTexthl': 'Todo',
|
||||
\ },
|
||||
\ 3: {
|
||||
\ 'name': 'Information',
|
||||
\ 'texthl': 'LanguageClientInfo',
|
||||
\ 'signText': g:spacevim_info_symbol,
|
||||
\ 'signTexthl': 'LanguageClientInfoSign',
|
||||
\ 'virtualTexthl': 'Todo',
|
||||
\ },
|
||||
\ 4: {
|
||||
\ 'name': 'Hint',
|
||||
\ 'texthl': 'LanguageClientInfo',
|
||||
\ 'signText': g:spacevim_info_symbol,
|
||||
\ 'signTexthl': 'LanguageClientInfoSign',
|
||||
\ 'virtualTexthl': 'Todo',
|
||||
\ },
|
||||
\ }
|
||||
|
||||
if g:spacevim_lint_engine ==# 'neomake'
|
||||
let g:LanguageClient_diagnosticsDisplay[1].texthl = 'NeomakeError'
|
||||
@ -119,9 +189,6 @@ function! SpaceVim#layers#lsp#config() abort
|
||||
let g:LanguageClient_autoStart = 1
|
||||
let g:lsp_async_completion = 1
|
||||
" }}}
|
||||
for ft in s:enabled_fts
|
||||
call SpaceVim#lsp#reg_server(ft, s:lsp_servers[ft])
|
||||
endfor
|
||||
endfunction
|
||||
|
||||
let s:enabled_fts = []
|
||||
@ -156,6 +223,7 @@ let s:lsp_servers = {
|
||||
\ }
|
||||
|
||||
function! SpaceVim#layers#lsp#set_variable(var) abort
|
||||
let s:enabled_clients = get(a:var, 'enabled_clients', s:enabled_clients)
|
||||
let override = get(a:var, 'override_cmd', {})
|
||||
if !empty(override)
|
||||
call extend(s:lsp_servers, override, 'force')
|
||||
@ -178,6 +246,10 @@ function! SpaceVim#layers#lsp#check_filetype(ft) abort
|
||||
return index(s:enabled_fts, a:ft) != -1
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#layers#lsp#check_server(server) abort
|
||||
return index(s:enabled_clients, a:server) != -1
|
||||
endfunction
|
||||
|
||||
function! s:jump_to_next_error() abort
|
||||
try
|
||||
lnext
|
||||
|
@ -8,8 +8,47 @@
|
||||
|
||||
scriptencoding utf-8
|
||||
|
||||
if exists('s:NVIM_VERSION')
|
||||
finish
|
||||
endif
|
||||
|
||||
if SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
|
||||
|
||||
let s:NVIM_VERSION = SpaceVim#api#import('neovim#version')
|
||||
|
||||
if (has('nvim-0.5.0') && s:NVIM_VERSION.is_release_version()) || has('nvim-0.6.0')
|
||||
" use neovim built-in lsp
|
||||
function! SpaceVim#lsp#reg_server(ft, cmds) abort
|
||||
lua require("spacevim.lsp").register(
|
||||
\ require("spacevim").eval("a:ft"),
|
||||
\ require("spacevim").eval("a:cmds")
|
||||
\ )
|
||||
endfunction
|
||||
function! SpaceVim#lsp#show_doc() abort
|
||||
lua require('lsp.plugin')
|
||||
\ .client.request('textDocument/hover',
|
||||
\ {}, require('spacevim.lsp').hover_callback)
|
||||
endfunction
|
||||
function! SpaceVim#lsp#go_to_def() abort
|
||||
lua vim.lsp.buf.definition()
|
||||
endfunction
|
||||
function! SpaceVim#lsp#go_to_declaration() abort
|
||||
lua vim.lsp.buf.declaration()
|
||||
endfunction
|
||||
function! SpaceVim#lsp#rename() abort
|
||||
" @todo add float prompt api
|
||||
" lua vim.lsp.buf.rename(require('spacevim.api.input').float_prompt())
|
||||
lua vim.lsp.buf.rename()
|
||||
endfunction
|
||||
function! SpaceVim#lsp#references() abort
|
||||
endfunction
|
||||
function! SpaceVim#lsp#go_to_typedef() abort
|
||||
endfunction
|
||||
function! SpaceVim#lsp#refactor() abort
|
||||
endfunction
|
||||
function! SpaceVim#lsp#go_to_impl() abort
|
||||
lua vim.lsp.buf.implementation()
|
||||
endfunction
|
||||
elseif SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_method') ==# 'coc'
|
||||
" use coc.nvim
|
||||
let s:coc_language_servers = {}
|
||||
let s:coc_language_servers_key_id_map = {}
|
||||
@ -89,18 +128,16 @@ if SpaceVim#layers#isLoaded('autocomplete') && get(g:, 'spacevim_autocomplete_me
|
||||
function! SpaceVim#lsp#references() abort
|
||||
call CocAction('jumpReferences')
|
||||
endfunction
|
||||
elseif has('nvim')
|
||||
" use LanguageClient-neovim
|
||||
function! SpaceVim#lsp#reg_server(ft, cmds) abort
|
||||
let g:LanguageClient_serverCommands[a:ft] = copy(a:cmds)
|
||||
endfunction
|
||||
|
||||
elseif has('nvim-0.4.3')
|
||||
function! SpaceVim#lsp#show_doc() abort
|
||||
call LanguageClient_textDocument_hover()
|
||||
lua require('lsp.plugin')
|
||||
\ .client.request('textDocument/hover',
|
||||
\ {}, require('spacevim.lsp').hover_callback)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#go_to_def() abort
|
||||
call LanguageClient_textDocument_definition()
|
||||
lua require('lsp.plugin')
|
||||
\ .client.request('textDocument/hover',
|
||||
\ {}, require('spacevim.lsp').hover_callback)
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#go_to_typedef() abort
|
||||
@ -123,13 +160,14 @@ elseif has('nvim')
|
||||
call LanguageClient_textDocument_declaration()
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#documentSymbol()
|
||||
function! SpaceVim#lsp#documentSymbol() abort
|
||||
call LanguageClient_textDocument_documentSymbol()
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#refactor() abort
|
||||
" @todo languageclient do not support refactor
|
||||
endfunction
|
||||
elseif has('nvim')
|
||||
else
|
||||
" use vim-lsp
|
||||
function! SpaceVim#lsp#reg_server(ft, cmds) abort
|
||||
@ -148,14 +186,24 @@ else
|
||||
function! SpaceVim#lsp#go_to_def() abort
|
||||
LspDefinition
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#go_to_declaration() abort
|
||||
LspDeclaration
|
||||
endfunction
|
||||
function! SpaceVim#lsp#rename() abort
|
||||
LspRename
|
||||
endfunction
|
||||
|
||||
function! SpaceVim#lsp#references() abort
|
||||
LspReferences
|
||||
endfunction
|
||||
function! SpaceVim#lsp#go_to_typedef() abort
|
||||
LspPeekTypeDefinition
|
||||
endfunction
|
||||
function! SpaceVim#lsp#refactor() abort
|
||||
LspCodeAction refactor
|
||||
endfunction
|
||||
function! SpaceVim#lsp#go_to_impl() abort
|
||||
LspImplementation
|
||||
endfunction
|
||||
endif
|
||||
|
||||
" vi: et sw=2 cc=80
|
||||
|
52
bundle/deoplete-lsp/.github/ISSUE_TEMPLATE.md
vendored
Normal file
52
bundle/deoplete-lsp/.github/ISSUE_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
**Warning: I will close the issue without the minimal init.vim and the reproduction instructions.**
|
||||
|
||||
# Problems summary
|
||||
|
||||
|
||||
## Expected
|
||||
|
||||
|
||||
## Environment Information
|
||||
|
||||
* deoplete and deoplete-lsp version (SHA1):
|
||||
|
||||
* OS:
|
||||
|
||||
* neovim/Vim `:version` output:
|
||||
|
||||
* `:checkhealth` or `:CheckHealth` result(neovim only):
|
||||
|
||||
## Provide a minimal init.vim/vimrc with less than 50 lines (Required!)
|
||||
|
||||
```vim
|
||||
" Your minimal init.vim/vimrc
|
||||
set runtimepath+=~/path/to/deoplete.nvim/
|
||||
set runtimepath+=~/path/to/deoplete-lsp/
|
||||
let g:deoplete#enable_at_startup = 1
|
||||
|
||||
" For Vim only
|
||||
"set runtimepath+=~/path/to/nvim-yarp/
|
||||
"set runtimepath+=~/path/to/vim-hug-neovim-rpc/
|
||||
```
|
||||
|
||||
|
||||
## How to reproduce the problem from neovim/Vim startup (Required!)
|
||||
|
||||
1. foo
|
||||
2. bar
|
||||
3. baz
|
||||
|
||||
|
||||
## Generate a logfile if appropriate
|
||||
|
||||
1. export NVIM_PYTHON_LOG_FILE=/tmp/log
|
||||
2. export NVIM_PYTHON_LOG_LEVEL=DEBUG
|
||||
3. nvim -u minimal.vimrc
|
||||
4. some works
|
||||
5. cat /tmp/log_{PID}
|
||||
|
||||
|
||||
## Screenshot (if possible)
|
||||
|
||||
|
||||
## Upload the log file
|
6
bundle/deoplete-lsp/.gitignore
vendored
Normal file
6
bundle/deoplete-lsp/.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
*.py[cod]
|
||||
doc/tags
|
||||
vim-themis
|
||||
.cache
|
||||
.mypy_cache
|
||||
tags
|
21
bundle/deoplete-lsp/LICENSE
Normal file
21
bundle/deoplete-lsp/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
License: MIT license
|
||||
AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
bundle/deoplete-lsp/README.md
Normal file
20
bundle/deoplete-lsp/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
# LSP Completion source for deoplete
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
* Install LSP enabled neovim(version 0.5.0+)
|
||||
|
||||
* Install the latest deoplete
|
||||
|
||||
* Install and configure nvim-lsp
|
||||
|
||||
https://github.com/neovim/nvim-lsp
|
||||
|
||||
## Configuration
|
||||
|
||||
* `g:deoplete#lsp#handler_enabled`: If you set it to v:false, you can disable
|
||||
hover handler.
|
||||
|
||||
* `g:deoplete#lsp#use_icons_for_candidates`: Set to v:true to enable icons for
|
||||
LSP candidates. Requires patched font: https://www.nerdfonts.com/
|
21
bundle/deoplete-lsp/autoload/deoplete/lsp.vim
Normal file
21
bundle/deoplete-lsp/autoload/deoplete/lsp.vim
Normal file
@ -0,0 +1,21 @@
|
||||
"=============================================================================
|
||||
" FILE: lsp.vim
|
||||
" License: MIT license
|
||||
"=============================================================================
|
||||
|
||||
function! deoplete#lsp#enable() abort
|
||||
if has('vim_starting')
|
||||
augroup deoplete#lsp
|
||||
autocmd!
|
||||
autocmd VimEnter * call deoplete#lsp#enable()
|
||||
augroup END
|
||||
|
||||
return 1
|
||||
endif
|
||||
|
||||
if deoplete#lsp#init#_is_handler_enabled()
|
||||
return 1
|
||||
endif
|
||||
|
||||
return deoplete#lsp#init#_enable_handler()
|
||||
endfunction
|
12
bundle/deoplete-lsp/autoload/deoplete/lsp/handler.vim
Normal file
12
bundle/deoplete-lsp/autoload/deoplete/lsp/handler.vim
Normal file
@ -0,0 +1,12 @@
|
||||
"=============================================================================
|
||||
" FILE: handler.vim
|
||||
" License: MIT license
|
||||
"=============================================================================
|
||||
|
||||
function! deoplete#lsp#handler#_init() abort
|
||||
augroup deoplete#lsp
|
||||
autocmd!
|
||||
autocmd InsertEnter * lua require'hover'.insert_enter_handler()
|
||||
autocmd InsertLeave * lua require'hover'.insert_leave_handler()
|
||||
augroup END
|
||||
endfunction
|
25
bundle/deoplete-lsp/autoload/deoplete/lsp/init.vim
Normal file
25
bundle/deoplete-lsp/autoload/deoplete/lsp/init.vim
Normal file
@ -0,0 +1,25 @@
|
||||
"=============================================================================
|
||||
" FILE: init.vim
|
||||
" License: MIT license
|
||||
"=============================================================================
|
||||
|
||||
if !exists('g:deoplete#lsp#handler_enabled')
|
||||
let g:deoplete#lsp#handler_enabled = v:true
|
||||
endif
|
||||
|
||||
if !exists('s:is_handler_enabled')
|
||||
let s:is_handler_enabled = v:false
|
||||
endif
|
||||
|
||||
function! deoplete#lsp#init#_is_handler_enabled() abort
|
||||
return s:is_handler_enabled
|
||||
endfunction
|
||||
|
||||
function! deoplete#lsp#init#_enable_handler() abort
|
||||
if !g:deoplete#lsp#handler_enabled
|
||||
return
|
||||
endif
|
||||
|
||||
call deoplete#lsp#handler#_init()
|
||||
let s:is_handler_enabled = v:true
|
||||
endfunction
|
36
bundle/deoplete-lsp/lua/candidates.lua
Normal file
36
bundle/deoplete-lsp/lua/candidates.lua
Normal file
@ -0,0 +1,36 @@
|
||||
--
|
||||
--------------------------------------------------------------------------------
|
||||
-- File: candidates.lua
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
local api = vim.api
|
||||
|
||||
local get_candidates = function(_, arg1, arg2)
|
||||
-- For neovim 0.6 breaking changes
|
||||
-- https://github.com/neovim/neovim/pull/15504
|
||||
local result = (vim.fn.has('nvim-0.6') == 1
|
||||
and type(arg1) == 'table' and arg1 or arg2)
|
||||
if not result or result == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
local success = (type(result) == 'table' and not vim.tbl_isempty(result)
|
||||
) and true or false
|
||||
result = result['items'] ~= nil and result['items'] or result
|
||||
|
||||
if #result > 0 then
|
||||
api.nvim_set_var('deoplete#source#lsp#_results', result)
|
||||
api.nvim_set_var('deoplete#source#lsp#_success', success)
|
||||
api.nvim_set_var('deoplete#source#lsp#_requested', true)
|
||||
api.nvim_call_function('deoplete#auto_complete', {})
|
||||
end
|
||||
end
|
||||
|
||||
local request_candidates = function(arguments)
|
||||
vim.lsp.buf_request(0, 'textDocument/completion', arguments, get_candidates)
|
||||
end
|
||||
|
||||
return {
|
||||
request_candidates = request_candidates
|
||||
}
|
160
bundle/deoplete-lsp/lua/hover.lua
Normal file
160
bundle/deoplete-lsp/lua/hover.lua
Normal file
@ -0,0 +1,160 @@
|
||||
--
|
||||
--------------------------------------------------------------------------------
|
||||
-- File: hover.lua
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
|
||||
local vim = vim
|
||||
local api = vim.api
|
||||
local feature = 'textDocument/hover'
|
||||
local default_response_handler = vim.lsp.handlers[feature]
|
||||
|
||||
local hover_initialise = {
|
||||
buffer_changes = 0,
|
||||
complete_item = nil,
|
||||
complete_item_index = -1,
|
||||
insert_mode = false,
|
||||
window = nil
|
||||
}
|
||||
|
||||
local hover = hover_initialise
|
||||
local util = require 'util'
|
||||
|
||||
local complete_visible = function()
|
||||
return vim.fn.pumvisible() ~= 0
|
||||
end
|
||||
|
||||
local get_markdown_lines = function(result)
|
||||
local markdown_lines = vim.lsp.util.convert_input_to_markdown_lines(result.contents)
|
||||
|
||||
return vim.lsp.util.trim_empty_lines(markdown_lines)
|
||||
end
|
||||
|
||||
local get_window_alignment = function(complete_columns, screen_columns)
|
||||
if complete_columns < screen_columns / 2 then
|
||||
alignment = 'right'
|
||||
else
|
||||
alignment = 'left'
|
||||
end
|
||||
|
||||
return alignment
|
||||
end
|
||||
|
||||
local create_window = function(method, result)
|
||||
return util.focusable_float(method, function()
|
||||
local markdown_lines = get_markdown_lines(result)
|
||||
if vim.tbl_isempty(markdown_lines) then return end
|
||||
|
||||
local complete_display_info = vim.fn.pum_getpos()
|
||||
local alignment = get_window_alignment(complete_display_info['col'], api.nvim_get_option('columns'))
|
||||
|
||||
local hover_buffer, hover_window
|
||||
|
||||
hover_buffer, hover_window = util.fancy_floating_markdown(markdown_lines, {
|
||||
pad_left = 1; pad_right = 1;
|
||||
col = complete_display_info['col']; width = complete_display_info['width']; row = vim.fn.winline();
|
||||
align = alignment;
|
||||
})
|
||||
|
||||
hover.window = hover_window
|
||||
|
||||
if hover_window ~= nil and api.nvim_win_is_valid(hover_window) then
|
||||
vim.lsp.util.close_preview_autocmd({"CursorMoved", "BufHidden", "InsertCharPre"}, hover_window)
|
||||
end
|
||||
|
||||
return hover_buffer, hover_window
|
||||
end)
|
||||
end
|
||||
|
||||
local handle_response = function(_, method, result)
|
||||
if complete_visible() == false then return default_response_handler(_, method, result, _) end
|
||||
if not (result and result.contents) then return end
|
||||
|
||||
return create_window(method, result)
|
||||
end
|
||||
|
||||
local set_response_handler = function()
|
||||
for _, client in pairs(vim.lsp.buf_get_clients(0)) do
|
||||
local current_response_handler = client.config.handlers[feature] or default_response_handler
|
||||
if current_response_handler == handle_response then return end
|
||||
|
||||
client.config.handlers[feature] = handle_response
|
||||
end
|
||||
end
|
||||
|
||||
local decode_user_data = function(user_data)
|
||||
if user_data == nil or (user_data ~= nil and #user_data == 0) then return end
|
||||
|
||||
return vim.fn.json_decode(user_data)
|
||||
end
|
||||
|
||||
local client_with_hover = function()
|
||||
for _, value in pairs(vim.lsp.buf_get_clients(0)) do
|
||||
if value.resolved_capabilities.hover == false then return false end
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
local buffer_changed = function()
|
||||
buffer_changes = api.nvim_buf_get_changedtick(0)
|
||||
if hover.buffer_changes == buffer_changes then return false end
|
||||
|
||||
hover.buffer_changes = buffer_changes
|
||||
|
||||
return hover.buffer_changes
|
||||
end
|
||||
|
||||
local close_window = function()
|
||||
if hover.window == nil or not api.nvim_win_is_valid(hover.window) then return end
|
||||
|
||||
api.nvim_win_close(hover.window, true)
|
||||
end
|
||||
|
||||
local get_complete_item = function()
|
||||
local complete_info = api.nvim_call_function('complete_info', {{ 'eval', 'selected', 'items', 'user_data' }})
|
||||
if complete_info['selected'] == -1 or complete_info['selected'] == hover.complete_item_index then return false end
|
||||
|
||||
hover.complete_item_index = complete_info['selected']
|
||||
|
||||
return complete_info['items'][hover.complete_item_index + 1]
|
||||
end
|
||||
|
||||
local request_hover = function()
|
||||
local complete_item = get_complete_item()
|
||||
if not complete_visible() or not buffer_changed() or not complete_item then return end
|
||||
|
||||
close_window()
|
||||
|
||||
if not client_with_hover() then return end
|
||||
|
||||
local decoded_user_data = decode_user_data(complete_item['user_data'])
|
||||
if decoded_user_data == nil then return end
|
||||
|
||||
set_response_handler()
|
||||
|
||||
return vim.lsp.buf_request(api.nvim_get_current_buf(), 'textDocument/hover', util.make_position_params())
|
||||
end
|
||||
|
||||
local insert_enter_handler = function()
|
||||
hover.insert_mode = true
|
||||
local timer = vim.loop.new_timer()
|
||||
|
||||
timer:start(100, 80, vim.schedule_wrap(function()
|
||||
request_hover()
|
||||
|
||||
if hover.insert_mode == false and timer:is_closing() == false then
|
||||
timer:stop()
|
||||
timer:close()
|
||||
end
|
||||
end))
|
||||
end
|
||||
|
||||
local insert_leave_handler = function()
|
||||
hover.insert_mode = false
|
||||
end
|
||||
|
||||
return {
|
||||
insert_enter_handler = insert_enter_handler,
|
||||
insert_leave_handler = insert_leave_handler
|
||||
}
|
279
bundle/deoplete-lsp/lua/util.lua
Normal file
279
bundle/deoplete-lsp/lua/util.lua
Normal file
@ -0,0 +1,279 @@
|
||||
--
|
||||
--------------------------------------------------------------------------------
|
||||
-- File: util.lua
|
||||
--------------------------------------------------------------------------------
|
||||
--
|
||||
-- https://github.com/neovim/neovim/blob/master/runtime/lua/vim/lsp/util.lua
|
||||
--
|
||||
-- Don't like some conventions here but minimal modifications will make easier to compare with original
|
||||
|
||||
local vim = vim
|
||||
local validate = vim.validate
|
||||
local api = vim.api
|
||||
|
||||
local M = {}
|
||||
|
||||
local function ok_or_nil(status, ...)
|
||||
if not status then return end
|
||||
return ...
|
||||
end
|
||||
local function npcall(fn, ...)
|
||||
return ok_or_nil(pcall(fn, ...))
|
||||
end
|
||||
|
||||
function M.make_floating_popup_options(width, height, opts)
|
||||
validate {
|
||||
opts = { opts, 't', true };
|
||||
}
|
||||
opts = opts or {}
|
||||
validate {
|
||||
["opts.offset_x"] = { opts.offset_x, 'n', true };
|
||||
["opts.offset_y"] = { opts.offset_y, 'n', true };
|
||||
}
|
||||
|
||||
local lines_above = vim.fn.winline() - 1
|
||||
local lines_below = vim.fn.winheight(0) - lines_above
|
||||
|
||||
local col
|
||||
|
||||
if lines_above < lines_below then
|
||||
height = math.min(lines_below, height)
|
||||
else
|
||||
height = math.min(lines_above, height)
|
||||
end
|
||||
|
||||
if opts.align == 'right' then
|
||||
col = opts.col + opts.width
|
||||
else
|
||||
col = opts.col - width - 1
|
||||
end
|
||||
|
||||
return {
|
||||
col = col,
|
||||
height = height,
|
||||
relative = 'editor',
|
||||
row = opts.row,
|
||||
focusable = false,
|
||||
style = 'minimal',
|
||||
width = width,
|
||||
}
|
||||
end
|
||||
|
||||
local function find_window_by_var(name, value)
|
||||
for _, win in ipairs(api.nvim_list_wins()) do
|
||||
if npcall(api.nvim_win_get_var, win, name) == value then
|
||||
return win
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M.focusable_float(unique_name, fn)
|
||||
if npcall(api.nvim_win_get_var, 0, unique_name) then
|
||||
return api.nvim_command("wincmd p")
|
||||
end
|
||||
|
||||
local bufnr = api.nvim_get_current_buf()
|
||||
|
||||
do
|
||||
local win = find_window_by_var(unique_name, bufnr)
|
||||
if win then
|
||||
api.nvim_win_close(win, true)
|
||||
end
|
||||
end
|
||||
|
||||
local pbufnr, pwinnr = fn()
|
||||
|
||||
if pbufnr then
|
||||
api.nvim_win_set_var(pwinnr, unique_name, bufnr)
|
||||
return pbufnr, pwinnr
|
||||
end
|
||||
end
|
||||
|
||||
-- Convert markdown into syntax highlighted regions by stripping the code
|
||||
-- blocks and converting them into highlighted code.
|
||||
-- This will by default insert a blank line separator after those code block
|
||||
-- regions to improve readability.
|
||||
function M.fancy_floating_markdown(contents, opts)
|
||||
local pad_left = opts and opts.pad_left
|
||||
local pad_right = opts and opts.pad_right
|
||||
local stripped = {}
|
||||
local highlights = {}
|
||||
|
||||
local max_width
|
||||
if opts.align == 'right' then
|
||||
local columns = api.nvim_get_option('columns')
|
||||
max_width = columns - opts.col - opts.width
|
||||
else
|
||||
max_width = opts.col - 1
|
||||
end
|
||||
|
||||
-- Didn't have time to investigate but this fixes popup offset by one display issue
|
||||
max_width = max_width - pad_left - pad_right
|
||||
|
||||
do
|
||||
local i = 1
|
||||
while i <= #contents do
|
||||
local line = contents[i]
|
||||
local ft = line:match("^```([a-zA-Z0-9_]*)$")
|
||||
if ft then
|
||||
local start = #stripped
|
||||
i = i + 1
|
||||
while i <= #contents do
|
||||
line = contents[i]
|
||||
if line == "```" then
|
||||
i = i + 1
|
||||
break
|
||||
end
|
||||
if #line > max_width then
|
||||
while #line > max_width do
|
||||
local trimmed_line = string.sub(line, 1, max_width)
|
||||
local index = trimmed_line:reverse():find(" ")
|
||||
if index == nil or index > #trimmed_line/2 then
|
||||
break
|
||||
else
|
||||
table.insert(stripped, string.sub(line, 1, max_width-index))
|
||||
line = string.sub(line, max_width-index+2, #line)
|
||||
end
|
||||
end
|
||||
table.insert(stripped, line)
|
||||
else
|
||||
table.insert(stripped, line)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
table.insert(highlights, {
|
||||
ft = ft;
|
||||
start = start + 1;
|
||||
finish = #stripped + 1 - 1
|
||||
})
|
||||
else
|
||||
if #line > max_width then
|
||||
while #line > max_width do
|
||||
local trimmed_line = string.sub(line, 1, max_width)
|
||||
-- local index = math.max(trimmed_line:reverse():find(" "), trimmed_line:reverse():find("/"))
|
||||
local index = trimmed_line:reverse():find(" ")
|
||||
if index == nil or index > #trimmed_line/2 then
|
||||
break
|
||||
else
|
||||
table.insert(stripped, string.sub(line, 1, max_width-index))
|
||||
line = string.sub(line, max_width-index+2, #line)
|
||||
end
|
||||
end
|
||||
table.insert(stripped, line)
|
||||
else
|
||||
table.insert(stripped, line)
|
||||
end
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local width = 0
|
||||
for i, v in ipairs(stripped) do
|
||||
v = v:gsub("\r", "")
|
||||
if pad_left then v = (" "):rep(pad_left)..v end
|
||||
if pad_right then v = v..(" "):rep(pad_right) end
|
||||
stripped[i] = v
|
||||
width = math.max(width, #v)
|
||||
end
|
||||
|
||||
if opts.align == 'right' then
|
||||
local columns = api.nvim_get_option('columns')
|
||||
if opts.col + opts.row + width > columns then
|
||||
width = columns - opts.col - opts.width - 1
|
||||
end
|
||||
else
|
||||
if width > opts.col then
|
||||
width = opts.col - 1
|
||||
end
|
||||
end
|
||||
|
||||
local insert_separator = true
|
||||
if insert_separator then
|
||||
for i, h in ipairs(highlights) do
|
||||
h.start = h.start + i - 1
|
||||
h.finish = h.finish + i - 1
|
||||
if h.finish + 1 <= #stripped then
|
||||
table.insert(stripped, h.finish + 1, string.rep("─", width))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- Make the floating window.
|
||||
local height = #stripped
|
||||
local bufnr = api.nvim_create_buf(false, true)
|
||||
local winnr
|
||||
if vim.g.completion_docked_hover == 1 then
|
||||
if height > vim.g.completion_docked_maximum_size then
|
||||
height = vim.g.completion_docked_maximum_size
|
||||
elseif height < vim.g.completion_docked_minimum_size then
|
||||
height = vim.g.completion_docked_minimum_size
|
||||
end
|
||||
local row
|
||||
if vim.fn.winline() > api.nvim_get_option('lines')/2 then
|
||||
row = 0
|
||||
else
|
||||
row = api.nvim_get_option('lines') - height
|
||||
end
|
||||
winnr = api.nvim_open_win(bufnr, false, {
|
||||
col = 0,
|
||||
height = height,
|
||||
relative = 'editor',
|
||||
row = row,
|
||||
focusable = true,
|
||||
style = 'minimal',
|
||||
width = api.nvim_get_option('columns'),
|
||||
})
|
||||
else
|
||||
local opt = M.make_floating_popup_options(width, height, opts)
|
||||
if opt.width <= 0 then return end
|
||||
winnr = api.nvim_open_win(bufnr, false, opt)
|
||||
end
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, false, stripped)
|
||||
|
||||
local cwin = vim.api.nvim_get_current_win()
|
||||
vim.api.nvim_set_current_win(winnr)
|
||||
|
||||
vim.cmd("ownsyntax markdown")
|
||||
local idx = 1
|
||||
local function highlight_region(ft, start, finish)
|
||||
if ft == '' then return end
|
||||
local name = ft..idx
|
||||
idx = idx + 1
|
||||
local lang = "@"..ft:upper()
|
||||
-- TODO(ashkan): better validation before this.
|
||||
if not pcall(vim.cmd, string.format("syntax include %s syntax/%s.vim", lang, ft)) then
|
||||
return
|
||||
end
|
||||
vim.cmd(string.format("syntax region %s start=+\\%%%dl+ end=+\\%%%dl+ contains=%s", name, start, finish + 1, lang))
|
||||
end
|
||||
for _, h in ipairs(highlights) do
|
||||
highlight_region(h.ft, h.start, h.finish)
|
||||
end
|
||||
|
||||
vim.api.nvim_set_current_win(cwin)
|
||||
return bufnr, winnr
|
||||
end
|
||||
|
||||
local str_utfindex = vim.str_utfindex
|
||||
local function make_position_param()
|
||||
local row, col = unpack(api.nvim_win_get_cursor(0))
|
||||
row = row - 1
|
||||
local line = api.nvim_buf_get_lines(0, row, row+1, true)[1]
|
||||
col = str_utfindex(line, col)
|
||||
return { line = row; character = col; }
|
||||
end
|
||||
|
||||
function M.make_position_params()
|
||||
return {
|
||||
textDocument = M.make_text_document_params();
|
||||
position = make_position_param()
|
||||
}
|
||||
end
|
||||
|
||||
function M.make_text_document_params()
|
||||
return { uri = vim.uri_from_bufnr(0) }
|
||||
end
|
||||
|
||||
return M
|
22
bundle/deoplete-lsp/plugin/deoplete/lsp.vim
Normal file
22
bundle/deoplete-lsp/plugin/deoplete/lsp.vim
Normal file
@ -0,0 +1,22 @@
|
||||
"=============================================================================
|
||||
" FILE: lsp.vim
|
||||
" License: MIT license
|
||||
"=============================================================================
|
||||
|
||||
if exists('g:loaded_deoplete_lsp')
|
||||
finish
|
||||
endif
|
||||
|
||||
let g:loaded_deoplete_lsp = 1
|
||||
|
||||
" Global options definition.
|
||||
if get(g:, 'deoplete#enable_at_startup', 0)
|
||||
call deoplete#lsp#enable()
|
||||
endif
|
||||
|
||||
let g:completion_docked_hover = get(
|
||||
\ g:, 'completion_docked_hover', 0)
|
||||
let g:completion_docked_maximum_size = get(
|
||||
\ g:, 'completion_docked_maximum_size', 10)
|
||||
let g:completion_docked_minimum_size = get(
|
||||
\ g:, 'completion_docked_minimum_size', 3)
|
184
bundle/deoplete-lsp/rplugin/python3/deoplete/source/lsp.py
Normal file
184
bundle/deoplete-lsp/rplugin/python3/deoplete/source/lsp.py
Normal file
@ -0,0 +1,184 @@
|
||||
# =============================================================================
|
||||
# FILE: lsp.py
|
||||
# AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com>
|
||||
# =============================================================================
|
||||
|
||||
import json
|
||||
import re
|
||||
|
||||
from deoplete.source.base import Base
|
||||
|
||||
|
||||
LSP_KINDS = [
|
||||
'Text',
|
||||
'Method',
|
||||
'Function',
|
||||
'Constructor',
|
||||
'Field',
|
||||
'Variable',
|
||||
'Class',
|
||||
'Interface',
|
||||
'Module',
|
||||
'Property',
|
||||
'Unit',
|
||||
'Value',
|
||||
'Enum',
|
||||
'Keyword',
|
||||
'Snippet',
|
||||
'Color',
|
||||
'File',
|
||||
'Reference',
|
||||
'Folder',
|
||||
'EnumMember',
|
||||
'Constant',
|
||||
'Struct',
|
||||
'Event',
|
||||
'Operator',
|
||||
'TypeParameter',
|
||||
]
|
||||
|
||||
LSP_KINDS_WITH_ICONS = [
|
||||
' [text] ',
|
||||
' [method] ',
|
||||
' [function] ',
|
||||
' [constructor]',
|
||||
'ﰠ [field] ',
|
||||
'𝒙 [variable] ',
|
||||
' [class] ',
|
||||
' [interface]',
|
||||
' [module] ',
|
||||
' [property] ',
|
||||
' [unit] ',
|
||||
' [value] ',
|
||||
' [enum] ',
|
||||
' [key] ',
|
||||
' [snippet] ',
|
||||
' [color] ',
|
||||
' [file] ',
|
||||
' [refrence] ',
|
||||
' [folder] ',
|
||||
' [enumMember]',
|
||||
' [constant] ',
|
||||
' [struct] ',
|
||||
' [event] ',
|
||||
' [operator] ',
|
||||
' [typeParameter]',
|
||||
]
|
||||
|
||||
|
||||
class Source(Base):
|
||||
def __init__(self, vim):
|
||||
Base.__init__(self, vim)
|
||||
|
||||
self.name = 'lsp'
|
||||
self.mark = '[lsp]'
|
||||
self.rank = 500
|
||||
self.input_pattern = r'(\.|:|->)$'
|
||||
self.is_volatile = True
|
||||
self.vars = {}
|
||||
self.vim.vars['deoplete#source#lsp#_results'] = []
|
||||
self.vim.vars['deoplete#source#lsp#_success'] = False
|
||||
self.vim.vars['deoplete#source#lsp#_requested'] = False
|
||||
self.vim.vars['deoplete#source#lsp#_prev_input'] = ''
|
||||
if 'deoplete#lsp#use_icons_for_candidates' not in self.vim.vars:
|
||||
self.vim.vars['deoplete#lsp#use_icons_for_candidates'] = False
|
||||
|
||||
self.lsp_kinds = LSP_KINDS
|
||||
|
||||
def gather_candidates(self, context):
|
||||
if not self.vim.call('has', 'nvim-0.5.0'):
|
||||
return []
|
||||
|
||||
prev_input = self.vim.vars['deoplete#source#lsp#_prev_input']
|
||||
if context['input'] == prev_input and self.vim.vars[
|
||||
'deoplete#source#lsp#_requested']:
|
||||
return self.process_candidates()
|
||||
|
||||
vars = self.vim.vars
|
||||
vars['deoplete#source#lsp#_requested'] = False
|
||||
vars['deoplete#source#lsp#_prev_input'] = context['input']
|
||||
vars['deoplete#source#lsp#_complete_position'] = context[
|
||||
'complete_position']
|
||||
|
||||
params = self.vim.call(
|
||||
'luaeval',
|
||||
'vim.lsp.util.make_position_params()')
|
||||
|
||||
self.vim.call(
|
||||
'luaeval', 'require("candidates").request_candidates('
|
||||
'_A.arguments)',
|
||||
{'arguments': params})
|
||||
|
||||
return []
|
||||
|
||||
def process_candidates(self):
|
||||
candidates = []
|
||||
vars = self.vim.vars
|
||||
results = vars['deoplete#source#lsp#_results']
|
||||
|
||||
if not results:
|
||||
return
|
||||
elif isinstance(results, dict):
|
||||
if 'items' not in results:
|
||||
self.print_error(
|
||||
'LSP results does not have "items" key:{}'.format(
|
||||
str(results)))
|
||||
return
|
||||
items = results['items']
|
||||
else:
|
||||
items = results
|
||||
|
||||
use_icons = vars['deoplete#lsp#use_icons_for_candidates']
|
||||
if use_icons:
|
||||
self.lsp_kinds = LSP_KINDS_WITH_ICONS
|
||||
|
||||
for rec in items:
|
||||
if 'textEdit' in rec and rec['textEdit'] is not None:
|
||||
textEdit = rec['textEdit']
|
||||
if ('range' in textEdit and textEdit['range']['start'] ==
|
||||
textEdit['range']['end']):
|
||||
previous_input = vars['deoplete#source#lsp#_prev_input']
|
||||
complete_position = vars[
|
||||
'deoplete#source#lsp#_complete_position']
|
||||
new_text = textEdit['newText']
|
||||
word = f'{previous_input[complete_position:]}{new_text}'
|
||||
else:
|
||||
word = textEdit['newText']
|
||||
elif rec.get('insertText', ''):
|
||||
if rec.get('insertTextFormat', 1) != 1:
|
||||
word = rec.get('entryName', rec.get('label'))
|
||||
else:
|
||||
word = rec['insertText']
|
||||
else:
|
||||
word = rec.get('entryName', rec.get('label'))
|
||||
|
||||
# Remove parentheses from word.
|
||||
# Note: some LSP includes snippet parentheses in word(newText)
|
||||
word = re.sub(r'[\(|<].*[\)|>](\$\d+)?', '', word)
|
||||
|
||||
item = {
|
||||
'word': word,
|
||||
'abbr': rec['label'],
|
||||
'dup': 0,
|
||||
'user_data': json.dumps({
|
||||
'lspitem': rec
|
||||
})
|
||||
}
|
||||
|
||||
if isinstance(rec.get('kind'), int):
|
||||
item['kind'] = self.lsp_kinds[rec['kind'] - 1]
|
||||
elif rec.get('insertTextFormat') == 2:
|
||||
item['kind'] = 'Snippet'
|
||||
|
||||
if rec.get('detail'):
|
||||
item['menu'] = rec['detail']
|
||||
|
||||
if isinstance(rec.get('documentation'), str):
|
||||
item['info'] = rec['documentation']
|
||||
elif (isinstance(rec.get('documentation'), dict) and
|
||||
'value' in rec['documentation']):
|
||||
item['info'] = rec['documentation']['value']
|
||||
|
||||
candidates.append(item)
|
||||
|
||||
return candidates
|
3
bundle/nvim-lspconfig/.codespellignorewords
Normal file
3
bundle/nvim-lspconfig/.codespellignorewords
Normal file
@ -0,0 +1,3 @@
|
||||
als
|
||||
edn
|
||||
esy
|
17
bundle/nvim-lspconfig/.editorconfig
Normal file
17
bundle/nvim-lspconfig/.editorconfig
Normal file
@ -0,0 +1,17 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
tab_width = 8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
charset = utf-8
|
||||
|
||||
[*.lua]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[{Makefile,**/Makefile,runtime/doc/*.txt}]
|
||||
indent_style = tab
|
||||
indent_size = 8
|
83
bundle/nvim-lspconfig/.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
83
bundle/nvim-lspconfig/.github/ISSUE_TEMPLATE/bug_report.yml
vendored
Normal file
@ -0,0 +1,83 @@
|
||||
name: Bug report
|
||||
description: Report a problem in nvim-lspconfig
|
||||
labels: [bug]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Before reporting: search existing issues and ensure you are running the latest nightly of neovim and the latest version of nvim-lspconfig. Note that this repository implements configuration and initialization of language servers. Implementation of the language server spec itself is located in the neovim core repository.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Description"
|
||||
description: "A short description of the problem you are reporting."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Neovim version"
|
||||
description: "Output of `nvim --version`"
|
||||
placeholder: |
|
||||
NVIM v0.6.0-dev+209-g0603eba6e
|
||||
Build type: Release
|
||||
LuaJIT 2.1.0-beta3
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Nvim-lspconfig version"
|
||||
description: "Commit hash"
|
||||
placeholder: 1344a859864d4e6d23d3f3adf56d49e6386ec0d2
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Operating system and version"
|
||||
placeholder: "macOS 11.5"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Affected language servers"
|
||||
description: "If this issue is specific to one or more language servers, list them here. If not, write 'all'."
|
||||
placeholder: "clangd"
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Steps to reproduce"
|
||||
description: "Steps to reproduce using the minimal config provided below."
|
||||
placeholder: |
|
||||
1. `nvim -nu minimal.lua`
|
||||
2. ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Actual behavior"
|
||||
description: "Observed behavior."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Expected behavior"
|
||||
description: "A description of the behavior you expected."
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Minimal config"
|
||||
render: Lua
|
||||
description: "You can download a minimal_init.lua via `curl -fLO https://raw.githubusercontent.com/neovim/nvim-lspconfig/master/test/minimal_init.lua`. Then edit it to include your language server and add necessary configuration and paste it here."
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Health check"
|
||||
description: "Run `:checkhealth lspconfig` and paste the results here."
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "LSP log"
|
||||
description: "If not using the `minimal_init.lua`, add `vim.lsp.set_log_level('debug')` to your LSP setup, upload the log file at `$HOME/.cache/nvim/lsp.log` to https://gist.github.com, and paste the link here."
|
||||
validations:
|
||||
required: true
|
||||
|
||||
|
||||
|
6
bundle/nvim-lspconfig/.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
6
bundle/nvim-lspconfig/.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: Question
|
||||
url: https://neovim.discourse.group/c/language-server-protocol-lsp/7
|
||||
about: Usage questions and support requests are answered in the Neovim Discourse
|
||||
|
24
bundle/nvim-lspconfig/.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
24
bundle/nvim-lspconfig/.github/ISSUE_TEMPLATE/feature_request.yml
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
name: Feature request
|
||||
description: Request a feature in nvim-lspconfig
|
||||
labels: [enhancement]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Before requesting a new feature, search existing issues. Implementation of the language server protocol itself is located in the neovim core repository, and general feature requests may be better suited for core.
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Language server"
|
||||
description: "Is the feature specific to a language server? If so, which one(s)?"
|
||||
placeholder: "clangd"
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: "Requested feature"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
label: "Other clients which have this feature"
|
||||
description: "Is the feature already implemented in another LSP client for (Neo)Vim? If so, which one(s)?"
|
||||
placeholder: "vim-lsp"
|
||||
|
11
bundle/nvim-lspconfig/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
vendored
Normal file
11
bundle/nvim-lspconfig/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
name: Pull Request
|
||||
about: Submit a pull request
|
||||
title: ''
|
||||
---
|
||||
|
||||
<!--
|
||||
If you want to make changes to the README.md, do so in scripts/README_template.md.
|
||||
The CONFIG.md is auto-generated with all the options from the various LSP configuration;
|
||||
do not edit it manually
|
||||
-->
|
21
bundle/nvim-lspconfig/.github/workflows/codespell.yml
vendored
Normal file
21
bundle/nvim-lspconfig/.github/workflows/codespell.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
name: codespell
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
codespell:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
python-version: ${{ matrix.python-version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install codespell
|
||||
- name: Use codespell
|
||||
run: |
|
||||
codespell --quiet-level=2 --check-hidden --skip=CONFIG.md --ignore-words=.codespellignorewords || exit
|
12
bundle/nvim-lspconfig/.github/workflows/commit_lint.yml
vendored
Normal file
12
bundle/nvim-lspconfig/.github/workflows/commit_lint.yml
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
on: [pull_request]
|
||||
jobs:
|
||||
lint-commits:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2.3.1
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: npm install --save-dev @commitlint/{cli,config-conventional}
|
||||
- run: |
|
||||
echo "module.exports = { extends: ['@commitlint/config-conventional'] };" > commitlint.config.js
|
||||
- run: npx commitlint --from HEAD~1 --to HEAD --verbose
|
85
bundle/nvim-lspconfig/.github/workflows/docgen.yml
vendored
Normal file
85
bundle/nvim-lspconfig/.github/workflows/docgen.yml
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
name: docgen
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
docgen:
|
||||
runs-on: [ubuntu-latest]
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: date +%F > todays-date
|
||||
- name: Restore cache for today's nightly.
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: _neovim
|
||||
key: ${{ runner.os }}-nightly-${{ hashFiles('todays-date') }}
|
||||
- name: Setup from neovim nightly and run docgen
|
||||
run: |
|
||||
curl -OL https://raw.githubusercontent.com/norcalli/bot-ci/master/scripts/github-actions-setup.sh
|
||||
source github-actions-setup.sh nightly-x64
|
||||
scripts/docgen.sh
|
||||
- name: Commit changes
|
||||
env:
|
||||
COMMIT_MSG: |
|
||||
[docgen] Update CONFIG.md
|
||||
skip-checks: true
|
||||
run: |
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git add CONFIG.md
|
||||
# Only commit and push if we have changes
|
||||
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push)
|
||||
vimdocgen:
|
||||
needs: docgen
|
||||
runs-on: [ubuntu-latest]
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: date +%F > todays-date
|
||||
- name: Restore cache for today's nightly.
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: build
|
||||
key: ${{ runner.os }}-appimage-${{ hashFiles('todays-date') }}
|
||||
|
||||
- name: Setup neovim nightly and install plugins
|
||||
run: |
|
||||
test -d build || {
|
||||
mkdir -p build
|
||||
wget https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage
|
||||
chmod +x nvim.appimage
|
||||
mv nvim.appimage ./build/nvim
|
||||
}
|
||||
mkdir -p ~/.local/share/nvim/site/pack/vendor/start
|
||||
git clone --depth 1 https://github.com/mjlbach/babelfish.nvim ~/.local/share/nvim/site/pack/vendor/start/babelfish.nvim
|
||||
git clone --depth 1 https://github.com/nvim-treesitter/nvim-treesitter ~/.local/share/nvim/site/pack/vendor/start/nvim-treesitter
|
||||
ln -s $(pwd) ~/.local/share/nvim/site/pack/vendor/start
|
||||
|
||||
- name: Build parser
|
||||
run: |
|
||||
export PACKPATH=$HOME/.local/share/nvim/site
|
||||
./build/nvim -u ~/.local/share/nvim/site/pack/vendor/start/babelfish.nvim/scripts/init.lua --headless -c 'TSInstallSync markdown' -c 'qa'
|
||||
- name: Generating docs
|
||||
run: |
|
||||
export PATH="${PWD}/build/:${PATH}"
|
||||
export PACKPATH=$HOME/.local/share/nvim/site
|
||||
./build/nvim -u ~/.local/share/nvim/site/pack/vendor/start/babelfish.nvim/scripts/init.lua --headless -c 'luafile ./scripts/vimdocgen.lua' -c 'qa'
|
||||
- name: Commit changes
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
COMMIT_MSG: |
|
||||
[docgen] Update README.md
|
||||
skip-checks: true
|
||||
run: |
|
||||
git config user.email "actions@github"
|
||||
git config user.name "Github Actions"
|
||||
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
|
||||
git add doc/lspconfig.txt
|
||||
# Only commit and push if we have changes
|
||||
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF})
|
32
bundle/nvim-lspconfig/.github/workflows/lint.yml
vendored
Normal file
32
bundle/nvim-lspconfig/.github/workflows/lint.yml
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
name: lint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: [ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup luacheck
|
||||
run: |
|
||||
sudo apt update &&
|
||||
sudo apt install -y lua5.1 luarocks &&
|
||||
sudo luarocks install luacheck
|
||||
- name: Run luacheck
|
||||
run: |
|
||||
sudo make lint
|
||||
style-lint:
|
||||
runs-on: [ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
- name: Lint with stylua
|
||||
uses: JohnnyMorganz/stylua-action@1.0.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
# CLI arguments
|
||||
args: --check .
|
54
bundle/nvim-lspconfig/.github/workflows/test.yml
vendored
Normal file
54
bundle/nvim-lspconfig/.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,54 @@
|
||||
name: test
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
ubuntu:
|
||||
runs-on: [ubuntu-latest]
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup build dependencies
|
||||
run: |
|
||||
sudo apt update &&
|
||||
sudo apt install -y ninja-build \
|
||||
gettext \
|
||||
libtool \
|
||||
libtool-bin \
|
||||
autoconf \
|
||||
automake \
|
||||
cmake \
|
||||
g++ \
|
||||
pkg-config \
|
||||
unzip \
|
||||
gperf \
|
||||
libluajit-5.1-dev \
|
||||
libunibilium-dev \
|
||||
libmsgpack-dev \
|
||||
libtermkey-dev \
|
||||
libvterm-dev \
|
||||
libjemalloc-dev \
|
||||
lua5.1 \
|
||||
lua-lpeg \
|
||||
lua-mpack \
|
||||
lua-bitop
|
||||
- name: Run test with building Nvim
|
||||
run: |
|
||||
make test
|
||||
macos:
|
||||
runs-on: [macos-latest]
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
- name: Setup build dependencies
|
||||
run: |
|
||||
rm -f /usr/local/bin/2to3
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)" &&
|
||||
brew install ninja libtool automake pkg-config gettext
|
||||
- name: Run test with building Nvim
|
||||
run: |
|
||||
make test
|
||||
|
2
bundle/nvim-lspconfig/.gitignore
vendored
Normal file
2
bundle/nvim-lspconfig/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.luacheckcache
|
||||
neovim
|
14
bundle/nvim-lspconfig/.luacheckrc
Normal file
14
bundle/nvim-lspconfig/.luacheckrc
Normal file
@ -0,0 +1,14 @@
|
||||
-- vim: ft=lua tw=80
|
||||
|
||||
-- Rerun tests only if their modification time changed.
|
||||
cache = true
|
||||
|
||||
ignore = {
|
||||
"212", -- Unused argument, In the case of callback function, _arg_name is easier to understand than _, so this option is set to off.
|
||||
"631", -- max_line_length, vscode pkg URL is too long
|
||||
}
|
||||
|
||||
-- Global objects defined by the C code
|
||||
read_globals = {
|
||||
"vim",
|
||||
}
|
8
bundle/nvim-lspconfig/.mergify.yml
Normal file
8
bundle/nvim-lspconfig/.mergify.yml
Normal file
@ -0,0 +1,8 @@
|
||||
pull_request_rules:
|
||||
- name: disallow changing a file
|
||||
conditions:
|
||||
- files=CONFIG.md
|
||||
actions:
|
||||
close:
|
||||
comment:
|
||||
message: "CONFIG.md is auto-generated: edit the lua source file instead (and re-read the PR template)."
|
6
bundle/nvim-lspconfig/.stylua.toml
Normal file
6
bundle/nvim-lspconfig/.stylua.toml
Normal file
@ -0,0 +1,6 @@
|
||||
column_width = 120
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferSingle"
|
||||
no_call_parentheses = true
|
164
bundle/nvim-lspconfig/ADVANCED_README.md
Normal file
164
bundle/nvim-lspconfig/ADVANCED_README.md
Normal file
@ -0,0 +1,164 @@
|
||||
## Advanced usage
|
||||
|
||||
**All provided examples are in Lua,** see `:help :lua-heredoc` to use Lua from your init.vim,
|
||||
or the quickstart above for an example of a lua heredoc.
|
||||
|
||||
Each config provides a `setup()` function to initialize the server with reasonable default
|
||||
initialization options and settings, as well as some server-specific commands. This is
|
||||
invoked in the following form, where `<server>` corresponds to the language server name
|
||||
in [CONFIG.md](CONFIG.md).
|
||||
|
||||
`setup()` takes optional arguments <config>, each of which overrides the respective
|
||||
part of the default configuration. The allowed arguments are detailed [below](#setup-function).
|
||||
```lua
|
||||
require'lspconfig'.<server>.setup{<config>}
|
||||
```
|
||||
|
||||
### Example: using the defaults
|
||||
|
||||
To use the defaults, just call `setup()` with an empty `config` parameter.
|
||||
For the `gopls` config, that would be:
|
||||
|
||||
```lua
|
||||
require'lspconfig'.gopls.setup{}
|
||||
```
|
||||
|
||||
### Example: override some defaults
|
||||
|
||||
To set some config properties at `setup()`, specify their keys. For example to
|
||||
change how the "project root" is found, set the `root_dir` key:
|
||||
|
||||
```lua
|
||||
local lspconfig = require'lspconfig'
|
||||
lspconfig.gopls.setup{
|
||||
root_dir = lspconfig.util.root_pattern('.git');
|
||||
}
|
||||
```
|
||||
|
||||
The [documentation](CONFIG.md) for each config lists default values and
|
||||
additional optional properties. For a more complicated example overriding
|
||||
the `name`, `log_level`, `message_level`, and `settings` of texlab:
|
||||
|
||||
```lua
|
||||
local lspconfig = require'lspconfig'
|
||||
lspconfig.texlab.setup{
|
||||
name = 'texlab_fancy';
|
||||
settings = {
|
||||
latex = {
|
||||
build = {
|
||||
onSave = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Example: custom config
|
||||
|
||||
To configure a custom/private server, just
|
||||
|
||||
1. load the lspconfig module: `local lspconfig = require('lspconfig')`,
|
||||
2. Define the config: `lspconfig.configs.foo_lsp = { … }`
|
||||
3. Call `setup()`: `lspconfig.foo_lsp.setup{}`
|
||||
|
||||
```lua
|
||||
local lspconfig = require'lspconfig'
|
||||
local configs = require'lspconfig/configs'
|
||||
-- Check if it's already defined for when reloading this file.
|
||||
if not lspconfig.foo_lsp then
|
||||
configs.foo_lsp = {
|
||||
default_config = {
|
||||
cmd = {'/home/ashkan/works/3rd/lua-language-server/run.sh'};
|
||||
filetypes = {'lua'};
|
||||
root_dir = function(fname)
|
||||
return lspconfig.util.find_git_ancestor(fname) or vim.loop.os_homedir()
|
||||
end;
|
||||
settings = {};
|
||||
};
|
||||
}
|
||||
end
|
||||
lspconfig.foo_lsp.setup{}
|
||||
```
|
||||
|
||||
### Example: override default config for all servers
|
||||
|
||||
If you want to change default configs for all servers, you can override default_config like this. In this example, we additionally add a check for log_level and message_level which can be passed to the server to control the verbosity of "window/logMessage".
|
||||
|
||||
```lua
|
||||
local lspconfig = require'lspconfig'
|
||||
lspconfig.util.default_config = vim.tbl_extend(
|
||||
"force",
|
||||
lspconfig.util.default_config,
|
||||
{
|
||||
autostart = false,
|
||||
handlers = {
|
||||
["window/logMessage"] = function(err, method, params, client_id)
|
||||
if params and params.type <= vim.lsp.protocol.MessageType.Log then
|
||||
vim.lsp.handlers["window/logMessage"](err, method, params, client_id)
|
||||
end
|
||||
end;
|
||||
["window/showMessage"] = function(err, method, params, client_id)
|
||||
if params and params.type <= vim.lsp.protocol.MessageType.Warning.Error then
|
||||
vim.lsp.handlers["window/showMessage"](err, method, params, client_id)
|
||||
end
|
||||
end;
|
||||
}
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## setup() function
|
||||
|
||||
setup() extends the arguments listed in `:help vim.lsp.start_client()`. **In addition to all of the arguments defined for start_client**, the following key/value pairs can be passed to the setup function:
|
||||
|
||||
```
|
||||
lspconfig.SERVER.setup{config}
|
||||
|
||||
The `config` parameter has the same shape as that of
|
||||
|vim.lsp.start_client()|, with these additions:
|
||||
|
||||
{root_dir}
|
||||
Required for some servers, optional for others.
|
||||
Function of the form `function(filename, bufnr)`.
|
||||
Called on new candidate buffers being attached-to.
|
||||
Returns either a root_dir or nil.
|
||||
|
||||
If a root_dir is returned, then this file will also be attached. You
|
||||
can optionally use {filetype} to help pre-filter by filetype.
|
||||
|
||||
If a root_dir is returned which is unique from any previously returned
|
||||
root_dir, a new server will be spawned with that root_dir.
|
||||
|
||||
If nil is returned, the buffer is skipped.
|
||||
|
||||
See |lspconfig.util.search_ancestors()| and the functions which use it:
|
||||
- |lspconfig.util.root_pattern(pattern1, pattern2...)| is a variadic function which
|
||||
takes string patterns as arguments, and finds an ancestor
|
||||
which contains one of the files matching the pattern.
|
||||
Each pattern can be a specific filename, such as ".git", or a glob.
|
||||
See `:help glob` for allowed patterns. This is equivalent to
|
||||
coc.nvim's "rootPatterns"
|
||||
- Related utilities for common tools:
|
||||
- |lspconfig.util.find_git_root()|
|
||||
- |lspconfig.util.find_node_modules_root()|
|
||||
- |lspconfig.util.find_package_json_root()|
|
||||
|
||||
{name}
|
||||
Defaults to the server's name.
|
||||
|
||||
{filetypes}
|
||||
Set of filetypes to filter for consideration by {root_dir}.
|
||||
May be empty.
|
||||
Server may specify a default value.
|
||||
|
||||
{autostart}
|
||||
Whether to automatically start a language server when a matching filetype is detected.
|
||||
Defaults to true.
|
||||
|
||||
{on_new_config}
|
||||
`function(new_config, new_root_dir)` will be executed after a new configuration has been
|
||||
created as a result of {root_dir} returning a unique value. You can use this
|
||||
as an opportunity to further modify the new_config or use it before it is
|
||||
sent to |vim.lsp.start_client()|. If you set a custom `on_new_config`, ensure that
|
||||
`new_config.cmd = cmd` is present within the function body.
|
||||
```
|
7959
bundle/nvim-lspconfig/CONFIG.md
Normal file
7959
bundle/nvim-lspconfig/CONFIG.md
Normal file
File diff suppressed because it is too large
Load Diff
73
bundle/nvim-lspconfig/CONTRIBUTING.md
Normal file
73
bundle/nvim-lspconfig/CONTRIBUTING.md
Normal file
@ -0,0 +1,73 @@
|
||||
## Requirements
|
||||
|
||||
- [Neovim](https://neovim.io/) 0.5 or later
|
||||
- Documentation is generated by `scripts/docgen.lua`.
|
||||
- Only works on unix, you can ignore it on Windows.
|
||||
- Lint task requires [luacheck](https://github.com/luarocks/luacheck#installation) and [stylua](https://github.com/JohnnyMorganz/StyLua).
|
||||
|
||||
## Lint
|
||||
|
||||
PRs are checked with Luacheck and stylua. To run the linter locally:
|
||||
|
||||
make lint
|
||||
stylua .
|
||||
|
||||
## Generating docs
|
||||
|
||||
> Note: Github Actions automatically generates the docs, so only modify
|
||||
> `README_template.md` or the `docs` object on the server config.
|
||||
> Don't modify `README.md` directly.
|
||||
|
||||
To preview the generated `README.md` locally, run `scripts/docgen.lua` from
|
||||
`nvim` (from the project root):
|
||||
|
||||
nvim -R -Es +'set rtp+=$PWD' +'luafile scripts/docgen.lua'
|
||||
|
||||
## Configs
|
||||
|
||||
The `configs` module is a singleton where configs are defined. In `vim.validate`
|
||||
parlance here is the "spec":
|
||||
|
||||
configs.SERVER_NAME = {
|
||||
default_config = {'t'};
|
||||
on_new_config = {'f', true};
|
||||
on_attach = {'f', true};
|
||||
commands = {'t', true};
|
||||
docs = {'t', true};
|
||||
}
|
||||
docs = {
|
||||
description = {'s', true};
|
||||
default_config = {'t', true};
|
||||
}
|
||||
|
||||
- Keys in `docs.default_config` match those of
|
||||
`configs.SERVER_NAME.default_config`, and can be used to specify custom
|
||||
documentation. This is useful for functions, whose docs cannot be easily
|
||||
auto-generated.
|
||||
- `commands` is a map of `name:definition` key:value pairs, where `definition`
|
||||
is a list whose first value is a function implementing the command and the
|
||||
rest are either array values which will be formed into flags for the command
|
||||
or special keys like `description`. Example:
|
||||
```
|
||||
commands = {
|
||||
TexlabBuild = {
|
||||
function()
|
||||
buf_build(0)
|
||||
end;
|
||||
"-range";
|
||||
description = "Build the current buffer";
|
||||
};
|
||||
};
|
||||
```
|
||||
|
||||
The `configs.__newindex` metamethod consumes the config definition and returns
|
||||
an object with a `setup()` method, to be invoked by users:
|
||||
|
||||
require'lspconfig'.SERVER_NAME.setup{}
|
||||
|
||||
After you set `configs.SERVER_NAME` you can add arbitrary language-specific
|
||||
functions to it if necessary.
|
||||
|
||||
Example:
|
||||
|
||||
configs.texlab.buf_build = buf_build
|
183
bundle/nvim-lspconfig/LICENSE.md
Normal file
183
bundle/nvim-lspconfig/LICENSE.md
Normal file
@ -0,0 +1,183 @@
|
||||
Copyright Neovim contributors. All rights reserved.
|
||||
|
||||
nvim-lsp is licensed under the terms of the Apache 2.0 license.
|
||||
|
||||
nvim-lsp's license follows:
|
||||
|
||||
====
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
10
bundle/nvim-lspconfig/Makefile
Normal file
10
bundle/nvim-lspconfig/Makefile
Normal file
@ -0,0 +1,10 @@
|
||||
test:
|
||||
sh ./scripts/run_test.sh
|
||||
lint:
|
||||
luacheck lua/* test/*
|
||||
|
||||
style-lint:
|
||||
stylua --check .
|
||||
|
||||
.PHONY: test lint style-lint
|
||||
|
208
bundle/nvim-lspconfig/README.md
Normal file
208
bundle/nvim-lspconfig/README.md
Normal file
@ -0,0 +1,208 @@
|
||||
# nvim-lspconfig
|
||||
|
||||
A [collection of common configurations](https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md) for Neovim's built-in [language server client](https://neovim.io/doc/user/lsp.html).
|
||||
|
||||
This repo handles automatically launching and initializing language servers that are installed on your system.
|
||||
|
||||
# LSP overview
|
||||
|
||||
Neovim supports the Language Server Protocol (LSP), which means it acts as a client to language servers and includes a Lua framework `vim.lsp` for building enhanced LSP tools. LSP facilitates features like:
|
||||
|
||||
- go-to-definition
|
||||
- find-references
|
||||
- hover
|
||||
- completion
|
||||
- rename
|
||||
- format
|
||||
- refactor
|
||||
|
||||
Neovim provides an interface for all of these features, and the language server client is designed to be highly extensible to allow plugins to integrate language server features which are not yet present in Neovim core such as [**auto**-completion](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion) (as opposed to manual completion with omnifunc) and [snippet integration](https://github.com/neovim/nvim-lspconfig/wiki/Snippets).
|
||||
|
||||
These features are not implemented in this repo, but in Neovim core. See `:help lsp` for more details.
|
||||
|
||||
## Install
|
||||
|
||||
* Requires [Neovim v0.5.0](https://github.com/neovim/neovim/releases/tag/v0.5.0) or [Nightly](https://github.com/neovim/neovim/releases/tag/nightly). Update Neovim and nvim-lspconfig before reporting an issue.
|
||||
|
||||
* Install nvim-lspconfig like any other Vim plugin, e.g. with [vim-plug](https://github.com/junegunn/vim-plug):
|
||||
|
||||
```vim
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
```
|
||||
|
||||
## Quickstart
|
||||
|
||||
1. Install a language server, e.g. [pyright](CONFIG.md#pyright)
|
||||
|
||||
```bash
|
||||
npm i -g pyright
|
||||
```
|
||||
|
||||
2. Add the language server setup to your init.vim. The server name must match those found in the table of contents in [CONFIG.md](CONFIG.md)
|
||||
|
||||
```lua
|
||||
lua << EOF
|
||||
require'lspconfig'.pyright.setup{}
|
||||
EOF
|
||||
```
|
||||
|
||||
3. Create a project, this project must contain a file matching the root directory trigger. See [Automatically launching language servers](#Automatically-launching-language-servers) for additional info.
|
||||
|
||||
```bash
|
||||
mkdir test_python_project
|
||||
cd test_python_project
|
||||
git init
|
||||
touch main.py
|
||||
```
|
||||
|
||||
4. Launch neovim, the language server will now be attached and providing diagnostics (see `:LspInfo`)
|
||||
|
||||
```
|
||||
nvim main.py
|
||||
```
|
||||
|
||||
5. See [Keybindings and completion](#Keybindings-and-completion) for mapping useful functions and enabling omnifunc completion
|
||||
|
||||
## Automatically launching language servers
|
||||
|
||||
In order to automatically launch a language server, lspconfig searches up the directory tree from your current buffer to find a file matching the `root_dir` pattern defined in each server's configuration. For [pyright](CONFIG.md#pyright), this is any directory containing ".git", "setup.py", "setup.cfg", "pyproject.toml", or "requirements.txt").
|
||||
|
||||
Language servers require each project to have a `root` in order to provide completion and search across symbols that may not be defined in your current file, and to avoid having to index your entire filesystem on each startup.
|
||||
|
||||
## Enabling additional language servers
|
||||
|
||||
Enabling most language servers is as easy as installing the language server, ensuring it is on your PATH, and adding the following to your config:
|
||||
|
||||
```vim
|
||||
lua << EOF
|
||||
require'lspconfig'.rust_analyzer.setup{}
|
||||
EOF
|
||||
```
|
||||
|
||||
For a full list of servers, see [CONFIG.md](CONFIG.md). This document contains installation instructions and additional, optional customization suggestions for each language server. For some servers that are not on your system path (jdtls, elixirls) you will be required to manually add `cmd` as an entry in the table passed to setup. Most language servers can be installed in less than a minute.
|
||||
|
||||
## Keybindings and completion
|
||||
|
||||
nvim-lspconfig does not map keybindings or enable completion by default. Manual, triggered completion can be provided by neovim's built-in omnifunc. For autocompletion, a general purpose [autocompletion plugin](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion) is required. The following example configuration provides suggested keymaps for the most commonly used language server functions, and manually triggered completion with omnifunc (\<c-x\>\<c-o\>).
|
||||
Note: **you must pass the defined `on_attach` as an argument to every `setup {}` call** and **the keybindings in `on_attach` only take effect after the language server has started (attached to the current buffer)**.
|
||||
|
||||
```lua
|
||||
lua << EOF
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, 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
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
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>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
end
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
EOF
|
||||
```
|
||||
|
||||
The `on_attach` hook is used to only activate the bindings after the language server attaches to the current buffer.
|
||||
|
||||
## Debugging
|
||||
|
||||
If you have an issue with lspconfig, the first step is to reproduce with a [minimal configuration](https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua).
|
||||
|
||||
The most common reasons a language server does not start or attach are:
|
||||
|
||||
1. The language server is not installed. nvim-lspconfig does not install language servers for you. You should be able to run the `cmd` defined in each server's lua module from the command line and see that the language server starts. If the `cmd` is an executable name, ensure it is on your path.
|
||||
|
||||
2. Not triggering root detection. The language server will only start if it is opened in a directory, or child directory, containing a file which signals the *root* of the project. Most of the time, this is a `.git` folder, but each server defines the root config in the lua file. See [CONFIG.md](CONFIG.md) or the source for the list of root directories.
|
||||
|
||||
3. Misconfiguration. You must pass `on_attach` and `capabilities` for **each** `setup {}` if you want these to take effect. You must also **not call `setup {}` twice for the same server**. The second call to `setup {}` will overwrite the first.
|
||||
|
||||
:LspInfo provides a handy overview of your active and configured language servers. Note, that it will not report any configuration changes applied in `on_new_config`.
|
||||
|
||||
Before reporting a bug, check your logs and the output of `:LspInfo`. Add the following to your init.vim to enable logging:
|
||||
|
||||
```lua
|
||||
lua << EOF
|
||||
vim.lsp.set_log_level("debug")
|
||||
EOF
|
||||
```
|
||||
Attempt to run the language server, and open the log with:
|
||||
```
|
||||
:lua vim.cmd('e'..vim.lsp.get_log_path())
|
||||
```
|
||||
Most of the time, the reason for failure is present in the logs.
|
||||
|
||||
## Built-in commands
|
||||
|
||||
* `:LspInfo` shows the status of active and configured language servers.
|
||||
|
||||
The following support tab-completion for all arguments:
|
||||
|
||||
* `:LspStart <config_name>` Start the requested server name. Will only successfully start if the command detects a root directory matching the current config. Pass `autostart = false` to your `.setup{}` call for a language server if you would like to launch clients solely with this command. Defaults to all servers matching current buffer filetype.
|
||||
* `:LspStop <client_id>` Defaults to stopping all buffer clients.
|
||||
* `:LspRestart <client_id>` Defaults to restarting all buffer clients.
|
||||
|
||||
## The wiki
|
||||
|
||||
Please see the [wiki](https://github.com/neovim/nvim-lspconfig/wiki) for additional topics, including:
|
||||
|
||||
* [Installing language servers automatically](https://github.com/neovim/nvim-lspconfig/wiki/Installing-language-servers-automatically)
|
||||
* [Snippets support](https://github.com/neovim/nvim-lspconfig/wiki/Snippets)
|
||||
* [Project local settings](https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings)
|
||||
* [Recommended plugins for enhanced language server features](https://github.com/neovim/nvim-lspconfig/wiki/Language-specific-plugins)
|
||||
|
||||
## Windows
|
||||
|
||||
In order for neovim to launch certain executables on Windows, it must append `.cmd` to the command name. To work around this, manually append `.cmd` to the entry `cmd` in a given plugin's setup{} call.
|
||||
|
||||
## Contributions
|
||||
|
||||
If you are missing a language server on the list in [CONFIG.md](CONFIG.md), contributing
|
||||
a new configuration for it would be appreciated. You can follow these steps:
|
||||
|
||||
1. Read [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
|
||||
2. Choose a language from [the coc.nvim wiki](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or
|
||||
[emacs-lsp](https://github.com/emacs-lsp/lsp-mode#supported-languages).
|
||||
|
||||
3. Create a new file at `lua/lspconfig/SERVER_NAME.lua`.
|
||||
|
||||
- Copy an [existing config](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/)
|
||||
to get started. Most configs are simple. For an extensive example see
|
||||
[texlab.lua](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/texlab.lua).
|
||||
|
||||
4. Ask questions on our [Discourse](https://neovim.discourse.group/c/7-category/7) or in the [Neovim Gitter](https://gitter.im/neovim/neovim).
|
4
bundle/nvim-lspconfig/autoload/health/lspconfig.vim
Normal file
4
bundle/nvim-lspconfig/autoload/health/lspconfig.vim
Normal file
@ -0,0 +1,4 @@
|
||||
function! health#lspconfig#check()
|
||||
call health#report_start('Checking language server protocol configuration')
|
||||
lua require 'lspconfig/health'.check_health()
|
||||
endfunction
|
240
bundle/nvim-lspconfig/doc/lspconfig.txt
Normal file
240
bundle/nvim-lspconfig/doc/lspconfig.txt
Normal file
@ -0,0 +1,240 @@
|
||||
==============================================================================
|
||||
1. nvim-lspconfig *lspconfig-nvim-lspconfig*
|
||||
|
||||
|
||||
A collection of common configurations for Neovim's built-in [language server client](https://neovim.io/doc/user/lsp.html).
|
||||
This repo handles automatically launching and initializing language servers
|
||||
that are installed on your system.
|
||||
==============================================================================
|
||||
2. LSP overview *lspconfig-lsp-overview*
|
||||
|
||||
|
||||
Neovim supports the Language Server Protocol (LSP), which means it acts as a
|
||||
client to language servers and includes a Lua framework `vim.lsp` for building
|
||||
enhanced LSP tools. LSP facilitates features like:
|
||||
- go-to-definition
|
||||
- find-references
|
||||
- hover
|
||||
- completion
|
||||
- rename
|
||||
- format
|
||||
- refactor
|
||||
Neovim provides an interface for all of these features, and the language server
|
||||
client is designed to be highly extensible to allow plugins to integrate
|
||||
language server features which are not yet present in Neovim core such as [**auto**-completion](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion)
|
||||
(as opposed to manual completion with omnifunc) and [snippet integration](https://github.com/neovim/nvim-lspconfig/wiki/Snippets).
|
||||
These features are not implemented in this repo, but in Neovim core. See `:help
|
||||
lsp` for more details.
|
||||
==============================================================================
|
||||
3. Install *lspconfig-install*
|
||||
|
||||
|
||||
* Requires [Neovim v0.5.0](https://github.com/neovim/neovim/releases/tag/v0.5.0) or [Nightly](https://github.com/neovim/neovim/releases/tag/nightly). Update Neovim and nvim-lspconfig before reporting an issue.
|
||||
* Install nvim-lspconfig like any other Vim plugin, e.g. with [vim-plug](https://github.com/junegunn/vim-plug):
|
||||
|
||||
```vim
|
||||
Plug 'neovim/nvim-lspconfig'
|
||||
```
|
||||
==============================================================================
|
||||
4. Quickstart *lspconfig-quickstart*
|
||||
|
||||
|
||||
1. Install a language server, e.g. [pyright](CONFIG.md#pyright)
|
||||
|
||||
```bash
|
||||
npm i -g pyright
|
||||
```
|
||||
2. Add the language server setup to your init.vim. The server name must match those found in the table of contents in [CONFIG.md](CONFIG.md)
|
||||
|
||||
```lua
|
||||
lua << EOF
|
||||
require'lspconfig'.pyright.setup{}
|
||||
EOF
|
||||
```
|
||||
3. Create a project, this project must contain a file matching the root directory trigger. See [Automatically launching language servers](#Automatically-launching-language-servers) for additional info.
|
||||
|
||||
```bash
|
||||
mkdir test_python_project
|
||||
cd test_python_project
|
||||
git init
|
||||
touch main.py
|
||||
```
|
||||
4. Launch neovim, the language server will now be attached and providing diagnostics (see `:LspInfo`)
|
||||
|
||||
```
|
||||
nvim main.py
|
||||
```
|
||||
5. See [Keybindings and completion](#Keybindings-and-completion) for mapping useful functions and enabling omnifunc completion
|
||||
==============================================================================
|
||||
5. Automatically launching language servers*lspconfig-automatically-launching-language-servers*
|
||||
|
||||
|
||||
In order to automatically launch a language server, lspconfig searches up the
|
||||
directory tree from your current buffer to find a file matching the `root_dir`
|
||||
pattern defined in each server's configuration. For [pyright](CONFIG.md#pyright)
|
||||
, this is any directory containing ".git", "setup.py", "setup.cfg",
|
||||
"pyproject.toml", or "requirements.txt").
|
||||
Language servers require each project to have a `root` in order to provide
|
||||
completion and search across symbols that may not be defined in your current
|
||||
file, and to avoid having to index your entire filesystem on each startup.
|
||||
==============================================================================
|
||||
6. Enabling additional language servers*lspconfig-enabling-additional-language-servers*
|
||||
|
||||
|
||||
Enabling most language servers is as easy as installing the language server,
|
||||
ensuring it is on your PATH, and adding the following to your config:
|
||||
|
||||
>
|
||||
lua << EOF
|
||||
require'lspconfig'.rust_analyzer.setup{}
|
||||
EOF
|
||||
<
|
||||
|
||||
|
||||
For a full list of servers, see [CONFIG.md](CONFIG.md). This document contains
|
||||
installation instructions and additional, optional customization suggestions
|
||||
for each language server. For some servers that are not on your system path
|
||||
(jdtls, elixirls) you will be required to manually add `cmd` as an entry in the
|
||||
table passed to setup. Most language servers can be installed in less than a
|
||||
minute.
|
||||
==============================================================================
|
||||
7. Keybindings *lspconfig-keybindings*
|
||||
|
||||
|
||||
nvim-lspconfig does not map keybindings or enable completion by default.
|
||||
Manual, triggered completion can be provided by neovim's built-in omnifunc. For
|
||||
autocompletion, a general purpose [autocompletion plugin](https://github.com/neovim/nvim-lspconfig/wiki/Autocompletion)
|
||||
is required. The following example configuration provides suggested keymaps for
|
||||
the most commonly used language server functions, and manually triggered
|
||||
completion with omnifunc ( \< c-x \> \< c-o \> ). Note: **you must pass the
|
||||
defined `on_attach` as an argument to every `setup {}` call** and **the
|
||||
keybindings in `on_attach` only take effect after the language server has
|
||||
started (attached to the current buffer)**.
|
||||
|
||||
>
|
||||
lua << EOF
|
||||
local nvim_lsp = require('lspconfig')
|
||||
|
||||
-- Use an on_attach function to only map the following keys
|
||||
-- after the language server attaches to the current buffer
|
||||
local on_attach = function(client, 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
|
||||
|
||||
-- Enable completion triggered by <c-x><c-o>
|
||||
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
-- Mappings.
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
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>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
||||
buf_set_keymap('n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
||||
buf_set_keymap('n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
||||
buf_set_keymap('n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
|
||||
end
|
||||
|
||||
-- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
-- map buffer local keybindings when the language server attaches
|
||||
local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
|
||||
for _, lsp in ipairs(servers) do
|
||||
nvim_lsp[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
}
|
||||
}
|
||||
end
|
||||
EOF
|
||||
<
|
||||
|
||||
|
||||
The `on_attach` hook is used to only activate the bindings after the language
|
||||
server attaches to the current buffer.
|
||||
==============================================================================
|
||||
8. Debugging *lspconfig-debugging*
|
||||
|
||||
|
||||
If you have an issue with lspconfig, the first step is to reproduce with a [minimal configuration](https://github.com/neovim/nvim-lspconfig/blob/master/test/minimal_init.lua).
|
||||
The most common reasons a language server does not start or attach are:
|
||||
1. The language server is not installed. nvim-lspconfig does not install language servers for you. You should be able to run the `cmd` defined in each server's lua module from the command line and see that the language server starts. If the `cmd` is an executable name, ensure it is on your path.
|
||||
2. Not triggering root detection. The language server will only start if it is opened in a directory, or child directory, containing a file which signals the *root* of the project. Most of the time, this is a `.git` folder, but each server defines the root config in the lua file. See [CONFIG.md](CONFIG.md) or the source for the list of root directories.
|
||||
3. Misconfiguration. You must pass `on_attach` and `capabilities` for **each** `setup {}` if you want these to take effect. You must also **not call `setup {}` twice for the same server**. The second call to `setup {}` will overwrite the first.
|
||||
:LspInfo provides a handy overview of your active and configured language
|
||||
servers. Note, that it will not report any configuration changes applied in
|
||||
`on_new_config`.
|
||||
Before reporting a bug, check your logs and the output of `:LspInfo`. Add the
|
||||
following to your init.vim to enable logging:
|
||||
|
||||
>
|
||||
lua << EOF
|
||||
vim.lsp.set_log_level("debug")
|
||||
EOF
|
||||
<
|
||||
|
||||
|
||||
Attempt to run the language server, and open the log with:
|
||||
|
||||
>
|
||||
:lua vim.cmd('e'..vim.lsp.get_log_path())
|
||||
<
|
||||
|
||||
|
||||
Most of the time, the reason for failure is present in the logs.
|
||||
==============================================================================
|
||||
9. Built-in commands *lspconfig-built-in-commands*
|
||||
|
||||
|
||||
* `:LspInfo` shows the status of active and configured language servers.
|
||||
The following support tab-completion for all arguments:
|
||||
* `:LspStart <config_name>` Start the requested server name. Will only successfully start if the command detects a root directory matching the current config. Pass `autostart = false` to your `.setup{}` call for a language server if you would like to launch clients solely with this command. Defaults to all servers matching current buffer filetype.
|
||||
* `:LspStop <client_id>` Defaults to stopping all buffer clients.
|
||||
* `:LspRestart <client_id>` Defaults to restarting all buffer clients.
|
||||
==============================================================================
|
||||
10. The wiki *lspconfig-the-wiki*
|
||||
|
||||
|
||||
Please see the [wiki](https://github.com/neovim/nvim-lspconfig/wiki) for
|
||||
additional topics, including:
|
||||
* [Installing language servers automatically](https://github.com/neovim/nvim-lspconfig/wiki/Installing-language-servers-automatically)
|
||||
* [Snippets support](https://github.com/neovim/nvim-lspconfig/wiki/Snippets)
|
||||
* [Project local settings](https://github.com/neovim/nvim-lspconfig/wiki/Project-local-settings)
|
||||
* [Recommended plugins for enhanced language server features](https://github.com/neovim/nvim-lspconfig/wiki/Language-specific-plugins)
|
||||
==============================================================================
|
||||
11. Windows *lspconfig-windows*
|
||||
|
||||
|
||||
In order for neovim to launch certain executables on Windows, it must append
|
||||
`.cmd` to the command name. To work around this, manually append `.cmd` to the
|
||||
entry `cmd` in a given plugin's setup{} call.
|
||||
==============================================================================
|
||||
12. Contributions *lspconfig-contributions*
|
||||
|
||||
|
||||
If you are missing a language server on the list in [CONFIG.md](CONFIG.md) ,
|
||||
contributing a new configuration for it would be appreciated. You can follow
|
||||
these steps:
|
||||
1. Read [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
2. Choose a language from [the coc.nvim wiki](https://github.com/neoclide/coc.nvim/wiki/Language-servers) or
|
||||
[emacs-lsp](https://github.com/emacs-lsp/lsp-mode#supported-languages).
|
||||
3. Create a new file at `lua/lspconfig/SERVER_NAME.lua`.
|
||||
|
||||
- Copy an [existing config](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/)
|
||||
to get started. Most configs are simple. For an extensive example see
|
||||
[texlab.lua](https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/texlab.lua).
|
||||
4. Ask questions on our [Discourse](https://neovim.discourse.group/c/7-category/7) or in the [Neovim Gitter](https://gitter.im/neovim/neovim).
|
||||
vim:tw=78:ts=8:ft=help:norl:
|
25
bundle/nvim-lspconfig/flake.lock
generated
Normal file
25
bundle/nvim-lspconfig/flake.lock
generated
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1626644568,
|
||||
"narHash": "sha256-+WxW0u6AJUn/AzIxUuNKtEDxSRcUP0v/iZ/tRXhLGEc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "d5bd34ebf2c2c2b380b76cb86bc68522bc6af4d7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
17
bundle/nvim-lspconfig/flake.nix
Normal file
17
bundle/nvim-lspconfig/flake.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
description = "Quickstart configurations for the Nvim LSP client";
|
||||
|
||||
outputs = { self, nixpkgs }: let
|
||||
pkgs = import nixpkgs { system = "x86_64-linux";};
|
||||
in {
|
||||
|
||||
devShell."x86_64-linux" = pkgs.mkShell {
|
||||
|
||||
buildInputs = [
|
||||
pkgs.stylua
|
||||
pkgs.luaPackages.luacheck
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
}
|
96
bundle/nvim-lspconfig/lua/lspconfig.lua
Normal file
96
bundle/nvim-lspconfig/lua/lspconfig.lua
Normal file
@ -0,0 +1,96 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
|
||||
local M = {
|
||||
util = require 'lspconfig/util',
|
||||
}
|
||||
|
||||
local script_path = M.util.script_path()
|
||||
|
||||
M._root = {}
|
||||
|
||||
function M.available_servers()
|
||||
return vim.tbl_keys(configs)
|
||||
end
|
||||
|
||||
-- Called from plugin/lspconfig.vim because it requires knowing that the last
|
||||
-- script in scriptnames to be executed is lspconfig.
|
||||
function M._root._setup()
|
||||
M._root.commands = {
|
||||
LspInfo = {
|
||||
function()
|
||||
require 'lspconfig/ui/lspinfo'()
|
||||
end,
|
||||
'-nargs=0',
|
||||
description = '`:LspInfo` Displays attached, active, and configured language servers',
|
||||
},
|
||||
LspStart = {
|
||||
function(server_name)
|
||||
if server_name then
|
||||
require('lspconfig')[server_name].autostart()
|
||||
else
|
||||
local buffer_filetype = vim.bo.filetype
|
||||
for client_name, config in pairs(configs) do
|
||||
if config.filetypes then
|
||||
for _, filetype_match in ipairs(config.filetypes) do
|
||||
if buffer_filetype == filetype_match then
|
||||
require('lspconfig')[client_name].autostart()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
'-nargs=? -complete=custom,v:lua.lsp_complete_configured_servers',
|
||||
description = '`:LspStart` Manually launches a language server.',
|
||||
},
|
||||
LspStop = {
|
||||
function(client_id)
|
||||
if not client_id then
|
||||
vim.lsp.stop_client(vim.lsp.get_active_clients())
|
||||
else
|
||||
local client = vim.lsp.get_client_by_id(tonumber(client_id))
|
||||
if client then
|
||||
client.stop()
|
||||
end
|
||||
end
|
||||
end,
|
||||
'-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids',
|
||||
description = '`:LspStop` Manually stops the given language client.',
|
||||
},
|
||||
LspRestart = {
|
||||
function(client_id)
|
||||
local clients
|
||||
|
||||
if client_id == nil then
|
||||
clients = vim.lsp.buf_get_clients(0)
|
||||
else
|
||||
clients = { vim.lsp.get_client_by_id(tonumber(client_id)) }
|
||||
end
|
||||
|
||||
for _, client in pairs(clients) do
|
||||
local client_name = client.name
|
||||
client.stop()
|
||||
vim.defer_fn(function()
|
||||
require('lspconfig')[client_name].autostart()
|
||||
end, 500)
|
||||
end
|
||||
end,
|
||||
'-nargs=? -complete=customlist,v:lua.lsp_get_active_client_ids',
|
||||
description = '`:LspRestart` Manually restart the given language client.',
|
||||
},
|
||||
}
|
||||
|
||||
M.util.create_module_commands('_root', M._root.commands)
|
||||
end
|
||||
|
||||
local mt = {}
|
||||
function mt:__index(k)
|
||||
if configs[k] == nil then
|
||||
-- dofile is used here as a performance hack to increase the speed of calls to setup({})
|
||||
-- dofile does not cache module lookups, and requires the absolute path to the target file
|
||||
pcall(dofile, script_path .. 'lspconfig/' .. k .. '.lua')
|
||||
end
|
||||
return configs[k]
|
||||
end
|
||||
|
||||
return setmetatable(M, mt)
|
41
bundle/nvim-lspconfig/lua/lspconfig/als.lua
Normal file
41
bundle/nvim-lspconfig/lua/lspconfig/als.lua
Normal file
@ -0,0 +1,41 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local server_name = 'als'
|
||||
local bin_name = 'ada_language_server'
|
||||
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
bin_name = 'ada_language_server.exe'
|
||||
end
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name },
|
||||
filetypes = { 'ada' },
|
||||
-- *.gpr and *.adc would be nice to have here
|
||||
root_dir = util.root_pattern('Makefile', '.git'),
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/AdaCore/ada_language_server/master/integration/vscode/ada/package.json',
|
||||
description = [[
|
||||
https://github.com/AdaCore/ada_language_server
|
||||
|
||||
Installation instructions can be found [here](https://github.com/AdaCore/ada_language_server#Install).
|
||||
|
||||
Can be configured by passing a "settings" object to `als.setup{}`:
|
||||
|
||||
```lua
|
||||
require('lspconfig').als.setup{
|
||||
settings = {
|
||||
ada = {
|
||||
projectFile = "project.gpr";
|
||||
scenarioVariables = { ... };
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[util.root_pattern("Makefile", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
70
bundle/nvim-lspconfig/lua/lspconfig/angularls.lua
Normal file
70
bundle/nvim-lspconfig/lua/lspconfig/angularls.lua
Normal file
@ -0,0 +1,70 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'angularls'
|
||||
|
||||
-- Angular requires a node_modules directory to probe for @angular/language-service and typescript
|
||||
-- in order to use your projects configured versions.
|
||||
-- This defaults to the vim cwd, but will get overwritten by the resolved root of the file.
|
||||
local function get_probe_dir(root_dir)
|
||||
local project_root = util.find_node_modules_ancestor(root_dir)
|
||||
|
||||
return project_root and (project_root .. '/node_modules') or ''
|
||||
end
|
||||
|
||||
local default_probe_dir = get_probe_dir(vim.fn.getcwd())
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = {
|
||||
'ngserver',
|
||||
'--stdio',
|
||||
'--tsProbeLocations',
|
||||
default_probe_dir,
|
||||
'--ngProbeLocations',
|
||||
default_probe_dir,
|
||||
},
|
||||
filetypes = { 'typescript', 'html', 'typescriptreact', 'typescript.tsx' },
|
||||
-- Check for angular.json or .git first since that is the root of the project.
|
||||
-- Don't check for tsconfig.json or package.json since there are multiple of these
|
||||
-- in an angular monorepo setup.
|
||||
root_dir = util.root_pattern('angular.json', '.git'),
|
||||
},
|
||||
on_new_config = function(new_config, new_root_dir)
|
||||
local new_probe_dir = get_probe_dir(new_root_dir)
|
||||
|
||||
-- We need to check our probe directories because they may have changed.
|
||||
new_config.cmd = {
|
||||
'ngserver',
|
||||
'--stdio',
|
||||
'--tsProbeLocations',
|
||||
new_probe_dir,
|
||||
'--ngProbeLocations',
|
||||
new_probe_dir,
|
||||
}
|
||||
end,
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/angular/vscode-ng-language-service
|
||||
|
||||
`angular-language-server` can be installed via npm `npm install -g @angular/language-server`.
|
||||
|
||||
Note, that if you override the default `cmd`, you must also update `on_new_config` to set `new_config.cmd` during startup.
|
||||
|
||||
```lua
|
||||
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,
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("angular.json", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
39
bundle/nvim-lspconfig/lua/lspconfig/ansiblels.lua
Normal file
39
bundle/nvim-lspconfig/lua/lspconfig/ansiblels.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local server_name = 'ansiblels'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { 'ansible-language-server', '--stdio' },
|
||||
settings = {
|
||||
ansible = {
|
||||
python = {
|
||||
interpreterPath = 'python',
|
||||
},
|
||||
ansibleLint = {
|
||||
path = 'ansible-lint',
|
||||
enabled = true,
|
||||
},
|
||||
ansible = {
|
||||
path = 'ansible',
|
||||
},
|
||||
},
|
||||
},
|
||||
filetypes = { 'yaml' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern { '*.yml', '*.yaml' }(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/ansible/ansible-language-server
|
||||
|
||||
Language server for the ansible configuration management tool.
|
||||
|
||||
`ansible-language-server` can be installed via `yarn`:
|
||||
```sh
|
||||
yarn global add ansible-language-server
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.arduino_language_server = {
|
||||
default_config = {
|
||||
cmd = { 'arduino-language-server' },
|
||||
filetypes = { 'arduino' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern '*.ino'(fname)
|
||||
end,
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/arduino/arduino-language-server
|
||||
|
||||
Language server for Arduino
|
||||
|
||||
The `arduino-language-server` can be installed by running:
|
||||
go get -u github.com/arduino/arduino-language-server
|
||||
|
||||
The `arduino-cli` tools must also be installed. Follow these instructions for your distro:
|
||||
https://arduino.github.io/arduino-cli/latest/installation/
|
||||
|
||||
After installing the `arduino-cli` tools, follow these instructions for generating
|
||||
a configuration file:
|
||||
https://arduino.github.io/arduino-cli/latest/getting-started/#create-a-configuration-file
|
||||
and make sure you install any relevant platforms libraries:
|
||||
https://arduino.github.io/arduino-cli/latest/getting-started/#install-the-core-for-your-board
|
||||
|
||||
The language server also requires `clangd` be installed. It will look for `clangd` by default but
|
||||
the binary path can be overridden if need be.
|
||||
|
||||
After all dependencies are installed you'll need to override the lspconfig command for the
|
||||
language server in your setup function with the necessary configurations:
|
||||
|
||||
```lua
|
||||
lspconfig.arduino_language_server.setup({
|
||||
cmd = {
|
||||
-- Required
|
||||
"arduino-language-server",
|
||||
"-cli-config", "/path/to/arduino-cli.yaml",
|
||||
-- Optional
|
||||
"-cli", "/path/to/arduino-cli",
|
||||
"-clangd", "/path/to/clangd"
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
For further instruction about configuration options, run `arduino-language-server --help`.
|
||||
|
||||
]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
31
bundle/nvim-lspconfig/lua/lspconfig/bashls.lua
Normal file
31
bundle/nvim-lspconfig/lua/lspconfig/bashls.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'bashls'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { 'bash-language-server', 'start' },
|
||||
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 = function(fname)
|
||||
return util.root_pattern '.git'(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/mads-hartmann/bash-language-server
|
||||
|
||||
Language server for bash, written using tree sitter in typescript.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = "vim's starting directory",
|
||||
},
|
||||
},
|
||||
}
|
31
bundle/nvim-lspconfig/lua/lspconfig/beancount.lua
Normal file
31
bundle/nvim-lspconfig/lua/lspconfig/beancount.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'beancount'
|
||||
local bin_name = 'beancount-langserver'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name },
|
||||
filetypes = { 'beancount' },
|
||||
root_dir = function(fname)
|
||||
return util.find_git_ancestor(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
init_options = {
|
||||
-- this is the path to the beancout journal file
|
||||
journalFile = '',
|
||||
-- this is the path to the python binary with beancount installed
|
||||
pythonPath = 'python3',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/polarmutex/beancount-language-server#installation
|
||||
|
||||
See https://github.com/polarmutex/beancount-language-server#configuration for configuration options
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("elm.json")]],
|
||||
},
|
||||
},
|
||||
}
|
39
bundle/nvim-lspconfig/lua/lspconfig/bicep.lua
Normal file
39
bundle/nvim-lspconfig/lua/lspconfig/bicep.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local server_name = 'bicep'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
filetypes = { 'bicep' },
|
||||
root_dir = util.root_pattern '.git',
|
||||
init_options = {},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/azure/bicep
|
||||
Bicep language server
|
||||
|
||||
Bicep language server can be installed by downloading and extracting a release of bicep-langserver.zip from [Bicep GitHub releases](https://github.com/Azure/bicep/releases).
|
||||
|
||||
Bicep language server requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
|
||||
|
||||
**By default, bicep language server doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of the unzipped run script or binary.
|
||||
|
||||
```lua
|
||||
local bicep_lsp_bin = "/path/to/bicep-langserver/Bicep.LangServer.dll"
|
||||
require'lspconfig'.bicep.setup{
|
||||
cmd = { "dotnet", bicep_lsp_bin };
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
To download the latest release and place in /usr/local/bin/bicep-langserver:
|
||||
```bash
|
||||
(cd $(mktemp -d) \
|
||||
&& curl -fLO https://github.com/Azure/bicep/releases/latest/download/bicep-langserver.zip \
|
||||
&& rm -rf /usr/local/bin/bicep-langserver \
|
||||
&& unzip -d /usr/local/bin/bicep-langserver bicep-langserver.zip)
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
44
bundle/nvim-lspconfig/lua/lspconfig/ccls.lua
Normal file
44
bundle/nvim-lspconfig/lua/lspconfig/ccls.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.ccls = {
|
||||
default_config = {
|
||||
cmd = { 'ccls' },
|
||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern('compile_commands.json', '.ccls', 'compile_flags.txt', '.git')(fname)
|
||||
or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/MaskRay/ccls/wiki
|
||||
|
||||
ccls relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified
|
||||
as compile_commands.json or, for simpler projects, a compile_flags.txt.
|
||||
For details on how to automatically generate one using CMake look [here](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html).
|
||||
|
||||
Customization options are passed to ccls at initialization time via init_options, a list of available options can be found [here](https://github.com/MaskRay/ccls/wiki/Customization#initialization-options). For example:
|
||||
|
||||
```lua
|
||||
local lspconfig = require'lspconfig'
|
||||
lspconfig.ccls.setup {
|
||||
init_options = {
|
||||
compilationDatabaseDirectory = "build";
|
||||
index = {
|
||||
threads = 0;
|
||||
};
|
||||
clang = {
|
||||
excludeArgs = { "-frounding-math"} ;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("compile_commands.json", ".ccls", "compile_flags.txt", ".git") or dirname]],
|
||||
},
|
||||
},
|
||||
}
|
81
bundle/nvim-lspconfig/lua/lspconfig/clangd.lua
Normal file
81
bundle/nvim-lspconfig/lua/lspconfig/clangd.lua
Normal file
@ -0,0 +1,81 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
-- https://clangd.llvm.org/extensions.html#switch-between-sourceheader
|
||||
local function switch_source_header(bufnr)
|
||||
bufnr = util.validate_bufnr(bufnr)
|
||||
local params = { uri = vim.uri_from_bufnr(bufnr) }
|
||||
vim.lsp.buf_request(
|
||||
bufnr,
|
||||
'textDocument/switchSourceHeader',
|
||||
params,
|
||||
util.compat_handler(function(err, result)
|
||||
if err then
|
||||
error(tostring(err))
|
||||
end
|
||||
if not result then
|
||||
print 'Corresponding file cannot be determined'
|
||||
return
|
||||
end
|
||||
vim.api.nvim_command('edit ' .. vim.uri_to_fname(result))
|
||||
end)
|
||||
)
|
||||
end
|
||||
|
||||
local root_pattern = util.root_pattern('compile_commands.json', 'compile_flags.txt', '.git')
|
||||
|
||||
local default_capabilities = vim.tbl_deep_extend(
|
||||
'force',
|
||||
util.default_config.capabilities or vim.lsp.protocol.make_client_capabilities(),
|
||||
{
|
||||
textDocument = {
|
||||
completion = {
|
||||
editsNearCursor = true,
|
||||
},
|
||||
},
|
||||
offsetEncoding = { 'utf-8', 'utf-16' },
|
||||
}
|
||||
)
|
||||
|
||||
configs.clangd = {
|
||||
default_config = {
|
||||
cmd = { 'clangd', '--background-index' },
|
||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp' },
|
||||
root_dir = function(fname)
|
||||
local filename = util.path.is_absolute(fname) and fname or util.path.join(vim.loop.cwd(), fname)
|
||||
return root_pattern(filename) or util.path.dirname(filename)
|
||||
end,
|
||||
on_init = function(client, result)
|
||||
if result.offsetEncoding then
|
||||
client.offset_encoding = result.offsetEncoding
|
||||
end
|
||||
end,
|
||||
capabilities = default_capabilities,
|
||||
},
|
||||
commands = {
|
||||
ClangdSwitchSourceHeader = {
|
||||
function()
|
||||
switch_source_header(0)
|
||||
end,
|
||||
description = 'Switch between source/header',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://clangd.llvm.org/installation.html
|
||||
|
||||
**NOTE:** Clang >= 9 is recommended! See [this issue for more](https://github.com/neovim/nvim-lsp/issues/23).
|
||||
|
||||
clangd relies on a [JSON compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) specified
|
||||
as compile_commands.json or, for simpler projects, a compile_flags.txt.
|
||||
For details on how to automatically generate one using CMake look [here](https://cmake.org/cmake/help/latest/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html).
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("compile_commands.json", "compile_flags.txt", ".git") or dirname]],
|
||||
on_init = [[function to handle changing offsetEncoding]],
|
||||
capabilities = [[default capabilities, with offsetEncoding utf-8]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
configs.clangd.switch_source_header = switch_source_header
|
20
bundle/nvim-lspconfig/lua/lspconfig/clojure_lsp.lua
Normal file
20
bundle/nvim-lspconfig/lua/lspconfig/clojure_lsp.lua
Normal file
@ -0,0 +1,20 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.clojure_lsp = {
|
||||
default_config = {
|
||||
cmd = { 'clojure-lsp' },
|
||||
filetypes = { 'clojure', 'edn' },
|
||||
root_dir = util.root_pattern('project.clj', 'deps.edn', '.git'),
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/snoe/clojure-lsp
|
||||
|
||||
Clojure Language Server
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("project.clj", "deps.edn", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
25
bundle/nvim-lspconfig/lua/lspconfig/cmake.lua
Normal file
25
bundle/nvim-lspconfig/lua/lspconfig/cmake.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.cmake = {
|
||||
default_config = {
|
||||
cmd = { 'cmake-language-server' },
|
||||
filetypes = { 'cmake' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern('.git', 'compile_commands.json', 'build')(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
init_options = {
|
||||
buildDirectory = 'build',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/regen100/cmake-language-server
|
||||
|
||||
CMake LSP Implementation
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern(".git", "compile_commands.json", "build") or dirname]],
|
||||
},
|
||||
},
|
||||
}
|
53
bundle/nvim-lspconfig/lua/lspconfig/codeqlls.lua
Normal file
53
bundle/nvim-lspconfig/lua/lspconfig/codeqlls.lua
Normal file
@ -0,0 +1,53 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'codeqlls'
|
||||
|
||||
local root_pattern = util.root_pattern 'qlpack.yml'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q' },
|
||||
filetypes = { 'ql' },
|
||||
root_dir = function(fname)
|
||||
return root_pattern(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
log_level = vim.lsp.protocol.MessageType.Warning,
|
||||
before_init = function(initialize_params)
|
||||
initialize_params['workspaceFolders'] = {
|
||||
{
|
||||
name = 'workspace',
|
||||
uri = initialize_params['rootUri'],
|
||||
},
|
||||
}
|
||||
end,
|
||||
settings = {
|
||||
search_path = vim.empty_dict(),
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
Reference:
|
||||
https://help.semmle.com/codeql/codeql-cli.html
|
||||
|
||||
Binaries:
|
||||
https://github.com/github/codeql-cli-binaries
|
||||
]],
|
||||
default_config = {
|
||||
settings = {
|
||||
search_path = [[list containing all search paths, eg: '~/codeql-home/codeql-repo']],
|
||||
},
|
||||
},
|
||||
},
|
||||
on_new_config = function(config)
|
||||
if type(config.settings.search_path) == 'table' and not vim.tbl_isempty(config.settings.search_path) then
|
||||
local search_path = '--search-path='
|
||||
for _, path in ipairs(config.settings.search_path) do
|
||||
search_path = search_path .. vim.fn.expand(path) .. ':'
|
||||
end
|
||||
config.cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q', search_path }
|
||||
else
|
||||
config.cmd = { 'codeql', 'execute', 'language-server', '--check-errors', 'ON_CHANGE', '-q' }
|
||||
end
|
||||
end,
|
||||
}
|
228
bundle/nvim-lspconfig/lua/lspconfig/configs.lua
Normal file
228
bundle/nvim-lspconfig/lua/lspconfig/configs.lua
Normal file
@ -0,0 +1,228 @@
|
||||
local util = require 'lspconfig/util'
|
||||
local api, validate, lsp = vim.api, vim.validate, vim.lsp
|
||||
local tbl_extend = vim.tbl_extend
|
||||
|
||||
local configs = {}
|
||||
|
||||
function configs.__newindex(t, config_name, config_def)
|
||||
validate {
|
||||
name = { config_name, 's' },
|
||||
default_config = { config_def.default_config, 't' },
|
||||
on_new_config = { config_def.on_new_config, 'f', true },
|
||||
on_attach = { config_def.on_attach, 'f', true },
|
||||
commands = { config_def.commands, 't', true },
|
||||
}
|
||||
if config_def.commands then
|
||||
for k, v in pairs(config_def.commands) do
|
||||
validate {
|
||||
['command.name'] = { k, 's' },
|
||||
['command.fn'] = { v[1], 'f' },
|
||||
}
|
||||
end
|
||||
else
|
||||
config_def.commands = {}
|
||||
end
|
||||
|
||||
local M = {}
|
||||
|
||||
local default_config = tbl_extend('keep', config_def.default_config, util.default_config)
|
||||
|
||||
-- Force this part.
|
||||
default_config.name = config_name
|
||||
|
||||
function M.setup(config)
|
||||
validate {
|
||||
cmd = { config.cmd, 't', true },
|
||||
root_dir = { config.root_dir, 'f', default_config.root_dir ~= nil },
|
||||
filetypes = { config.filetype, 't', true },
|
||||
on_new_config = { config.on_new_config, 'f', true },
|
||||
on_attach = { config.on_attach, 'f', true },
|
||||
commands = { config.commands, 't', true },
|
||||
}
|
||||
if config.commands then
|
||||
for k, v in pairs(config.commands) do
|
||||
validate {
|
||||
['command.name'] = { k, 's' },
|
||||
['command.fn'] = { v[1], 'f' },
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
config = tbl_extend('keep', config, default_config)
|
||||
|
||||
if util.on_setup then
|
||||
pcall(util.on_setup, config)
|
||||
end
|
||||
|
||||
local trigger
|
||||
if config.filetypes then
|
||||
trigger = 'FileType ' .. table.concat(config.filetypes, ',')
|
||||
else
|
||||
trigger = 'BufReadPost *'
|
||||
end
|
||||
if not (config.autostart == false) then
|
||||
api.nvim_command(
|
||||
string.format("autocmd %s unsilent lua require'lspconfig'[%q].manager.try_add()", trigger, config.name)
|
||||
)
|
||||
end
|
||||
|
||||
local get_root_dir = config.root_dir
|
||||
|
||||
function M.autostart()
|
||||
local root_dir = get_root_dir(api.nvim_buf_get_name(0), api.nvim_get_current_buf())
|
||||
if not root_dir then
|
||||
vim.notify(string.format('Autostart for %s failed: matching root directory not detected.', config_name))
|
||||
return
|
||||
end
|
||||
api.nvim_command(
|
||||
string.format(
|
||||
"autocmd %s unsilent lua require'lspconfig'[%q].manager.try_add_wrapper()",
|
||||
'BufReadPost ' .. root_dir .. '/*',
|
||||
config.name
|
||||
)
|
||||
)
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
local buf_dir = api.nvim_buf_get_name(bufnr)
|
||||
if buf_dir:sub(1, root_dir:len()) == root_dir then
|
||||
M.manager.try_add_wrapper(bufnr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Used by :LspInfo
|
||||
M.get_root_dir = get_root_dir
|
||||
M.filetypes = config.filetypes
|
||||
M.handlers = config.handlers
|
||||
M.cmd = config.cmd
|
||||
M._autostart = config.autostart
|
||||
|
||||
-- In the case of a reload, close existing things.
|
||||
local reload = false
|
||||
if M.manager then
|
||||
for _, client in ipairs(M.manager.clients()) do
|
||||
client.stop(true)
|
||||
end
|
||||
reload = true
|
||||
M.manager = nil
|
||||
end
|
||||
|
||||
local make_config = function(_root_dir)
|
||||
local new_config = vim.tbl_deep_extend('keep', vim.empty_dict(), config)
|
||||
new_config = vim.tbl_deep_extend('keep', new_config, default_config)
|
||||
new_config.capabilities = new_config.capabilities or lsp.protocol.make_client_capabilities()
|
||||
new_config.capabilities = vim.tbl_deep_extend('keep', new_config.capabilities, {
|
||||
workspace = {
|
||||
configuration = true,
|
||||
},
|
||||
})
|
||||
|
||||
if config_def.on_new_config then
|
||||
pcall(config_def.on_new_config, new_config, _root_dir)
|
||||
end
|
||||
if config.on_new_config then
|
||||
pcall(config.on_new_config, new_config, _root_dir)
|
||||
end
|
||||
|
||||
new_config.on_init = util.add_hook_after(new_config.on_init, function(client, _result)
|
||||
function client.workspace_did_change_configuration(settings)
|
||||
if not settings then
|
||||
return
|
||||
end
|
||||
if vim.tbl_isempty(settings) then
|
||||
settings = { [vim.type_idx] = vim.types.dictionary }
|
||||
end
|
||||
return client.notify('workspace/didChangeConfiguration', {
|
||||
settings = settings,
|
||||
})
|
||||
end
|
||||
if not vim.tbl_isempty(new_config.settings) then
|
||||
client.workspace_did_change_configuration(new_config.settings)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Save the old _on_attach so that we can reference it via the BufEnter.
|
||||
new_config._on_attach = new_config.on_attach
|
||||
new_config.on_attach = vim.schedule_wrap(function(client, bufnr)
|
||||
if bufnr == api.nvim_get_current_buf() then
|
||||
M._setup_buffer(client.id, bufnr)
|
||||
else
|
||||
api.nvim_command(
|
||||
string.format(
|
||||
"autocmd BufEnter <buffer=%d> ++once lua require'lspconfig'[%q]._setup_buffer(%d,%d)",
|
||||
bufnr,
|
||||
config_name,
|
||||
client.id,
|
||||
bufnr
|
||||
)
|
||||
)
|
||||
end
|
||||
end)
|
||||
|
||||
new_config.root_dir = _root_dir
|
||||
return new_config
|
||||
end
|
||||
|
||||
local manager = util.server_per_root_dir_manager(function(_root_dir)
|
||||
return make_config(_root_dir)
|
||||
end)
|
||||
|
||||
function manager.try_add(bufnr)
|
||||
bufnr = bufnr or api.nvim_get_current_buf()
|
||||
if vim.api.nvim_buf_get_option(bufnr, 'buftype') == 'nofile' then
|
||||
return
|
||||
end
|
||||
local root_dir = get_root_dir(api.nvim_buf_get_name(bufnr), bufnr)
|
||||
local id = manager.add(root_dir)
|
||||
if id then
|
||||
lsp.buf_attach_client(bufnr, id)
|
||||
end
|
||||
end
|
||||
|
||||
function manager.try_add_wrapper(bufnr)
|
||||
local buf_filetype = vim.api.nvim_buf_get_option(bufnr, 'filetype')
|
||||
for _, filetype in ipairs(config.filetypes) do
|
||||
if buf_filetype == filetype then
|
||||
manager.try_add(bufnr)
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
M.manager = manager
|
||||
M.make_config = make_config
|
||||
if reload and not (config.autostart == false) then
|
||||
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
|
||||
manager.try_add_wrapper(bufnr)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function M._setup_buffer(client_id, bufnr)
|
||||
local client = lsp.get_client_by_id(client_id)
|
||||
if not client then
|
||||
return
|
||||
end
|
||||
if client.config._on_attach then
|
||||
client.config._on_attach(client, bufnr)
|
||||
end
|
||||
if client.config.commands and not vim.tbl_isempty(client.config.commands) then
|
||||
M.commands = vim.tbl_deep_extend('force', M.commands, client.config.commands)
|
||||
end
|
||||
if not M.commands_created and not vim.tbl_isempty(M.commands) then
|
||||
-- Create the module commands
|
||||
util.create_module_commands(config_name, M.commands)
|
||||
M.commands_created = true
|
||||
end
|
||||
end
|
||||
|
||||
M.commands_created = false
|
||||
M.commands = config_def.commands
|
||||
M.name = config_name
|
||||
M.document_config = config_def
|
||||
|
||||
rawset(t, config_name, M)
|
||||
|
||||
return M
|
||||
end
|
||||
|
||||
return setmetatable({}, configs)
|
22
bundle/nvim-lspconfig/lua/lspconfig/crystalline.lua
Normal file
22
bundle/nvim-lspconfig/lua/lspconfig/crystalline.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.crystalline = {
|
||||
default_config = {
|
||||
cmd = { 'crystalline' },
|
||||
filetypes = { 'crystal' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern 'shard.yml'(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/elbywan/crystalline
|
||||
|
||||
Crystal language server.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern('shard.yml', '.git') or dirname]],
|
||||
},
|
||||
},
|
||||
}
|
26
bundle/nvim-lspconfig/lua/lspconfig/csharp_ls.lua
Normal file
26
bundle/nvim-lspconfig/lua/lspconfig/csharp_ls.lua
Normal file
@ -0,0 +1,26 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'csharp_ls'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { 'csharp-ls' },
|
||||
root_dir = util.root_pattern('*.sln', '*.csproj', '.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`.
|
||||
]],
|
||||
},
|
||||
}
|
47
bundle/nvim-lspconfig/lua/lspconfig/cssls.lua
Normal file
47
bundle/nvim-lspconfig/lua/lspconfig/cssls.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'cssls'
|
||||
local bin_name = 'vscode-css-language-server'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'css', 'scss', 'less' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern('package.json', '.git')(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
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]],
|
||||
},
|
||||
},
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.cucumber_language_server = {
|
||||
default_config = {
|
||||
cmd = { 'cucumber-language-server', '--stdio' },
|
||||
filetypes = { 'cucumber' },
|
||||
root_dir = util.root_pattern '.git',
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/cucumber/common/main/language-server/javascript/package.json',
|
||||
description = [[
|
||||
https://cucumber.io
|
||||
https://github.com/cucumber/common
|
||||
https://www.npmjs.com/package/@cucumber/language-server
|
||||
|
||||
Language server for Cucumber.
|
||||
|
||||
`cucumber-language-server` can be installed via `npm`:
|
||||
```sh
|
||||
npm install -g @cucumber/language-server
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern(".git")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
58
bundle/nvim-lspconfig/lua/lspconfig/dartls.lua
Normal file
58
bundle/nvim-lspconfig/lua/lspconfig/dartls.lua
Normal file
@ -0,0 +1,58 @@
|
||||
local util = require 'lspconfig/util'
|
||||
local configs = require 'lspconfig/configs'
|
||||
|
||||
local server_name = 'dartls'
|
||||
local bin_name = 'dart'
|
||||
|
||||
local find_dart_sdk_root_path = function()
|
||||
if os.getenv 'FLUTTER_SDK' then
|
||||
local flutter_path = os.getenv 'FLUTTER_SDK'
|
||||
return util.path.join(flutter_path, 'cache', 'dart-sdk', 'bin', 'dart')
|
||||
elseif vim.fn['executable'] 'flutter' == 1 then
|
||||
local flutter_path = vim.fn['resolve'](vim.fn['exepath'] 'flutter')
|
||||
local flutter_bin = vim.fn['fnamemodify'](flutter_path, ':h')
|
||||
return util.path.join(flutter_bin, 'cache', 'dart-sdk', 'bin', 'dart')
|
||||
elseif vim.fn['executable'] 'dart' == 1 then
|
||||
return vim.fn['resolve'](vim.fn['exepath'] 'dart')
|
||||
else
|
||||
return ''
|
||||
end
|
||||
end
|
||||
|
||||
local analysis_server_snapshot_path = function()
|
||||
local dart_sdk_root_path = vim.fn['fnamemodify'](find_dart_sdk_root_path(), ':h')
|
||||
local snapshot = util.path.join(dart_sdk_root_path, 'snapshots', 'analysis_server.dart.snapshot')
|
||||
|
||||
if vim.fn['has'] 'win32' == 1 or vim.fn['has'] 'win64' == 1 then
|
||||
snapshot = snapshot:gsub('/', '\\')
|
||||
end
|
||||
|
||||
return snapshot
|
||||
end
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, analysis_server_snapshot_path(), '--lsp' },
|
||||
filetypes = { 'dart' },
|
||||
root_dir = util.root_pattern 'pubspec.yaml',
|
||||
init_options = {
|
||||
onlyAnalyzeProjectsWithOpenFiles = false,
|
||||
suggestFromUnimportedLibraries = true,
|
||||
closingLabels = false,
|
||||
outline = false,
|
||||
flutterOutline = false,
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/Dart-Code/Dart-Code/master/package.json',
|
||||
description = [[
|
||||
https://github.com/dart-lang/sdk/tree/master/pkg/analysis_server/tool/lsp_spec
|
||||
|
||||
Language server for dart.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("pubspec.yaml")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
158
bundle/nvim-lspconfig/lua/lspconfig/denols.lua
Normal file
158
bundle/nvim-lspconfig/lua/lspconfig/denols.lua
Normal file
@ -0,0 +1,158 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local lsp = vim.lsp
|
||||
|
||||
local server_name = 'denols'
|
||||
|
||||
local function deno_uri_to_uri(uri)
|
||||
-- denols returns deno:/https/deno.land/std%400.85.0/http/server.ts
|
||||
-- nvim-lsp only handles deno://
|
||||
if string.sub(uri, 1, 6) == 'deno:/' and string.sub(uri, 7, 7) ~= '/' then
|
||||
return string.gsub(uri, '^deno:/', 'deno://', 1)
|
||||
end
|
||||
return uri
|
||||
end
|
||||
|
||||
local function uri_to_deno_uri(uri)
|
||||
-- denols use deno:/ and nvim-lsp use deno:// as buffer_uri.
|
||||
-- When buffer_uri is deno://, change uri to deno:/.
|
||||
if string.sub(uri, 1, 7) == 'deno://' and string.sub(uri, 8, 8) ~= '/' then
|
||||
return string.gsub(uri, '^deno://', 'deno:/', 1)
|
||||
end
|
||||
return uri
|
||||
end
|
||||
|
||||
local function buf_cache(bufnr)
|
||||
local params = {}
|
||||
params['referrer'] = { uri = vim.uri_from_bufnr(bufnr) }
|
||||
params['uris'] = {}
|
||||
lsp.buf_request(bufnr, 'deno/cache', params, function(err)
|
||||
if err then
|
||||
error(tostring(err))
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
local function virtual_text_document_handler(uri, result)
|
||||
if not result then
|
||||
return nil
|
||||
end
|
||||
|
||||
for client_id, res in pairs(result) do
|
||||
local lines = vim.split(res.result, '\n')
|
||||
local bufnr = vim.uri_to_bufnr(deno_uri_to_uri(uri))
|
||||
|
||||
local current_buf = vim.api.nvim_buf_get_lines(bufnr, 0, -1, false)
|
||||
if #current_buf ~= 0 then
|
||||
return nil
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_lines(bufnr, 0, -1, nil, lines)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'readonly', true)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'modified', false)
|
||||
vim.api.nvim_buf_set_option(bufnr, 'modifiable', false)
|
||||
lsp.buf_attach_client(bufnr, client_id)
|
||||
end
|
||||
end
|
||||
|
||||
local function virtual_text_document(uri)
|
||||
local params = {
|
||||
textDocument = {
|
||||
uri = uri,
|
||||
},
|
||||
}
|
||||
local result = lsp.buf_request_sync(0, 'deno/virtualTextDocument', params)
|
||||
virtual_text_document_handler(uri, result)
|
||||
end
|
||||
|
||||
local function denols_handler(err, method, result)
|
||||
if not result or vim.tbl_isempty(result) then
|
||||
return nil
|
||||
end
|
||||
|
||||
for _, res in pairs(result) do
|
||||
local uri = res.uri or res.targetUri
|
||||
if string.sub(uri, 1, 6) == 'deno:/' then
|
||||
virtual_text_document(uri)
|
||||
res['uri'] = deno_uri_to_uri(uri)
|
||||
res['targetUri'] = deno_uri_to_uri(uri)
|
||||
end
|
||||
end
|
||||
|
||||
lsp.handlers[method](err, method, result)
|
||||
end
|
||||
|
||||
local function denols_definition()
|
||||
local params = lsp.util.make_position_params()
|
||||
params.textDocument.uri = uri_to_deno_uri(params.textDocument.uri)
|
||||
lsp.buf_request(0, 'textDocument/definition', params)
|
||||
end
|
||||
|
||||
local function denols_references(context)
|
||||
vim.validate { context = { context, 't', true } }
|
||||
local params = lsp.util.make_position_params()
|
||||
params.context = context or {
|
||||
includeDeclaration = true,
|
||||
}
|
||||
params[vim.type_idx] = vim.types.dictionary
|
||||
params.textDocument.uri = uri_to_deno_uri(params.textDocument.uri)
|
||||
lsp.buf_request(0, 'textDocument/references', params)
|
||||
end
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { 'deno', 'lsp' },
|
||||
filetypes = {
|
||||
'javascript',
|
||||
'javascriptreact',
|
||||
'javascript.jsx',
|
||||
'typescript',
|
||||
'typescriptreact',
|
||||
'typescript.tsx',
|
||||
},
|
||||
root_dir = util.root_pattern('package.json', 'tsconfig.json', '.git'),
|
||||
init_options = {
|
||||
enable = true,
|
||||
lint = false,
|
||||
unstable = false,
|
||||
},
|
||||
handlers = {
|
||||
['textDocument/definition'] = denols_handler,
|
||||
['textDocument/references'] = denols_handler,
|
||||
},
|
||||
},
|
||||
commands = {
|
||||
DenolsDefinition = {
|
||||
denols_definition,
|
||||
description = 'Jump to definition. This handle deno:/ schema in deno:// buffer.',
|
||||
},
|
||||
DenolsReferences = {
|
||||
function()
|
||||
denols_references { includeDeclaration = true }
|
||||
end,
|
||||
description = 'List references. This handle deno:/ schema in deno:// buffer.',
|
||||
},
|
||||
DenolsCache = {
|
||||
function()
|
||||
buf_cache(0)
|
||||
end,
|
||||
description = 'Cache a module and all of its dependencies.',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/denoland/deno
|
||||
|
||||
Deno's built-in language server
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("package.json", "tsconfig.json", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
configs.denols.definition = denols_definition
|
||||
configs.denols.references = denols_references
|
||||
configs.denols.buf_cache = buf_cache
|
||||
configs.denols.virtual_text_document = virtual_text_document
|
||||
-- vim:et ts=2 sw=2
|
28
bundle/nvim-lspconfig/lua/lspconfig/dhall_lsp_server.lua
Normal file
28
bundle/nvim-lspconfig/lua/lspconfig/dhall_lsp_server.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.dhall_lsp_server = {
|
||||
default_config = {
|
||||
cmd = { 'dhall-lsp-server' },
|
||||
filetypes = { 'dhall' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern '.git'(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/dhall-lang/dhall-haskell/tree/master/dhall-lsp-server
|
||||
|
||||
language server for dhall
|
||||
|
||||
`dhall-lsp-server` can be installed via cabal:
|
||||
```sh
|
||||
cabal install dhall-lsp-server
|
||||
```
|
||||
prebuilt binaries can be found [here](https://github.com/dhall-lang/dhall-haskell/releases).
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern(".git") or dirname]],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
28
bundle/nvim-lspconfig/lua/lspconfig/diagnosticls.lua
Normal file
28
bundle/nvim-lspconfig/lua/lspconfig/diagnosticls.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'diagnosticls'
|
||||
local bin_name = 'diagnostic-languageserver'
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
bin_name = bin_name .. '.cmd'
|
||||
end
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = {},
|
||||
root_dir = util.path.dirname,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/iamcco/diagnostic-languageserver
|
||||
|
||||
Diagnostic language server integrate with linters.
|
||||
]],
|
||||
default_config = {
|
||||
filetypes = 'Empty by default, override to add filetypes',
|
||||
root_dir = "Vim's starting directory",
|
||||
init_options = 'Configuration from https://github.com/iamcco/diagnostic-languageserver#config--document',
|
||||
},
|
||||
},
|
||||
}
|
28
bundle/nvim-lspconfig/lua/lspconfig/dockerls.lua
Normal file
28
bundle/nvim-lspconfig/lua/lspconfig/dockerls.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'dockerls'
|
||||
local bin_name = 'docker-langserver'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'Dockerfile', 'dockerfile' },
|
||||
root_dir = util.root_pattern 'Dockerfile',
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/rcjsuen/dockerfile-language-server-nodejs
|
||||
|
||||
`docker-langserver` can be installed via `npm`:
|
||||
```sh
|
||||
npm install -g dockerfile-language-server-nodejs
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("Dockerfile")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
29
bundle/nvim-lspconfig/lua/lspconfig/dotls.lua
Normal file
29
bundle/nvim-lspconfig/lua/lspconfig/dotls.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'dotls'
|
||||
local bin_name = 'dot-language-server'
|
||||
|
||||
local root_files = {
|
||||
'.git',
|
||||
}
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'dot' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern(unpack(root_files))(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/nikeee/dot-language-server
|
||||
|
||||
`dot-language-server` can be installed via `npm`:
|
||||
```sh
|
||||
npm install -g dot-language-server
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
38
bundle/nvim-lspconfig/lua/lspconfig/efm.lua
Normal file
38
bundle/nvim-lspconfig/lua/lspconfig/efm.lua
Normal file
@ -0,0 +1,38 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'efm'
|
||||
local bin_name = 'efm-langserver'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern '.git'(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/mattn/efm-langserver
|
||||
|
||||
General purpose Language Server that can use specified error message format generated from specified command.
|
||||
|
||||
Note: In order for neovim's built-in language server client to send the appropriate `languageId` to EFM, **you must
|
||||
specify `filetypes` in your call to `setup{}`**. Otherwise `lspconfig` will launch EFM on the `BufEnter` instead
|
||||
of the `FileType` autocommand, and the `filetype` variable used to populate the `languageId` will not yet be set.
|
||||
|
||||
```lua
|
||||
require('lspconfig')['efm'].setup{
|
||||
settings = ..., -- You must populate this according to the EFM readme
|
||||
filetypes = { 'python','cpp','lua' }
|
||||
}
|
||||
```
|
||||
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[util.root_pattern(".git")(fname) or util.path.dirname(fname)]],
|
||||
},
|
||||
},
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
44
bundle/nvim-lspconfig/lua/lspconfig/elixirls.lua
Normal file
44
bundle/nvim-lspconfig/lua/lspconfig/elixirls.lua
Normal file
@ -0,0 +1,44 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'elixirls'
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
filetypes = { 'elixir', 'eelixir' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern('mix.exs', '.git')(fname) or vim.loop.os_homedir()
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/elixir-lsp/vscode-elixir-ls/master/package.json',
|
||||
description = [[
|
||||
https://github.com/elixir-lsp/elixir-ls
|
||||
|
||||
`elixir-ls` can be installed by following the instructions [here](https://github.com/elixir-lsp/elixir-ls#building-and-running).
|
||||
|
||||
```bash
|
||||
curl -fLO https://github.com/elixir-lsp/elixir-ls/releases/latest/download/elixir-ls.zip
|
||||
unzip elixir-ls.zip -d /path/to/elixir-ls
|
||||
# Unix
|
||||
chmod +x /path/to/elixir-ls/language_server.sh
|
||||
```
|
||||
|
||||
**By default, elixir-ls doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of your unzipped elixir-ls.
|
||||
|
||||
```lua
|
||||
require'lspconfig'.elixirls.setup{
|
||||
-- Unix
|
||||
cmd = { "/path/to/elixir-ls/language_server.sh" };
|
||||
-- Windows
|
||||
cmd = { "/path/to/elixir-ls/language_server.bat" };
|
||||
...
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("mix.exs", ".git") or vim.loop.os_homedir()]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
47
bundle/nvim-lspconfig/lua/lspconfig/elmls.lua
Normal file
47
bundle/nvim-lspconfig/lua/lspconfig/elmls.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local lsp = vim.lsp
|
||||
local api = vim.api
|
||||
|
||||
local server_name = 'elmls'
|
||||
local bin_name = 'elm-language-server'
|
||||
|
||||
local default_capabilities = lsp.protocol.make_client_capabilities()
|
||||
default_capabilities.offsetEncoding = { 'utf-8', 'utf-16' }
|
||||
local elm_root_pattern = util.root_pattern 'elm.json'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name },
|
||||
-- TODO(ashkan) if we comment this out, it will allow elmls to operate on elm.json. It seems like it could do that, but no other editor allows it right now.
|
||||
filetypes = { 'elm' },
|
||||
root_dir = function(fname)
|
||||
local filetype = api.nvim_buf_get_option(0, 'filetype')
|
||||
if filetype == 'elm' or (filetype == 'json' and fname:match 'elm%.json$') then
|
||||
return elm_root_pattern(fname)
|
||||
end
|
||||
end,
|
||||
init_options = {
|
||||
elmPath = 'elm',
|
||||
elmFormatPath = 'elm-format',
|
||||
elmTestPath = 'elm-test',
|
||||
elmAnalyseTrigger = 'change',
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/elm-tooling/elm-language-client-vscode/master/package.json',
|
||||
description = [[
|
||||
https://github.com/elm-tooling/elm-language-server#installation
|
||||
|
||||
If you don't want to use Nvim to install it, then you can use:
|
||||
```sh
|
||||
npm install -g elm elm-test elm-format @elm-tooling/elm-language-server
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("elm.json")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
29
bundle/nvim-lspconfig/lua/lspconfig/ember.lua
Normal file
29
bundle/nvim-lspconfig/lua/lspconfig/ember.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'ember'
|
||||
local bin_name = 'ember-language-server'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'handlebars', 'typescript', 'javascript' },
|
||||
root_dir = util.root_pattern('ember-cli-build.js', '.git'),
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/lifeart/ember-language-server
|
||||
|
||||
`ember-language-server` can be installed via `npm`:
|
||||
|
||||
```sh
|
||||
npm install -g @lifeart/ember-language-server
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("ember-cli-build.js", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
31
bundle/nvim-lspconfig/lua/lspconfig/erlangls.lua
Normal file
31
bundle/nvim-lspconfig/lua/lspconfig/erlangls.lua
Normal file
@ -0,0 +1,31 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.erlangls = {
|
||||
default_config = {
|
||||
cmd = { 'erlang_ls' },
|
||||
filetypes = { 'erlang' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern('rebar.config', 'erlang.mk', '.git')(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://erlang-ls.github.io
|
||||
|
||||
Language Server for Erlang.
|
||||
|
||||
Clone [erlang_ls](https://github.com/erlang-ls/erlang_ls)
|
||||
Compile the project with `make` and copy resulting binaries somewhere in your $PATH eg. `cp _build/*/bin/* ~/local/bin`
|
||||
|
||||
Installation instruction can be found [here](https://github.com/erlang-ls/erlang_ls).
|
||||
|
||||
Installation requirements:
|
||||
- [Erlang OTP 21+](https://github.com/erlang/otp)
|
||||
- [rebar3 3.9.1+](https://github.com/erlang/rebar3)
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern('rebar.config', 'erlang.mk', '.git') or util.path.dirname(fname)]],
|
||||
},
|
||||
},
|
||||
}
|
30
bundle/nvim-lspconfig/lua/lspconfig/flow.lua
Normal file
30
bundle/nvim-lspconfig/lua/lspconfig/flow.lua
Normal file
@ -0,0 +1,30 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.flow = {
|
||||
default_config = {
|
||||
cmd = { 'npx', '--no-install', 'flow', 'lsp' },
|
||||
filetypes = { 'javascript', 'javascriptreact', 'javascript.jsx' },
|
||||
root_dir = util.root_pattern '.flowconfig',
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/flowtype/flow-for-vscode/master/package.json',
|
||||
description = [[
|
||||
https://flow.org/
|
||||
https://github.com/facebook/flow
|
||||
|
||||
See below for how to setup Flow itself.
|
||||
https://flow.org/en/docs/install/
|
||||
|
||||
See below for lsp command options.
|
||||
|
||||
```sh
|
||||
npx flow lsp --help
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern(".flowconfig")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
25
bundle/nvim-lspconfig/lua/lspconfig/fortls.lua
Normal file
25
bundle/nvim-lspconfig/lua/lspconfig/fortls.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.fortls = {
|
||||
default_config = {
|
||||
cmd = { 'fortls' },
|
||||
filetypes = { 'fortran' },
|
||||
root_dir = util.root_pattern '.fortls',
|
||||
settings = {
|
||||
nthreads = 1,
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/hansec/vscode-fortran-ls/master/package.json',
|
||||
description = [[
|
||||
https://github.com/hansec/fortran-language-server
|
||||
|
||||
Fortran Language Server for the Language Server Protocol
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern(".fortls")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
-- vim:et ts=2 sw=2
|
35
bundle/nvim-lspconfig/lua/lspconfig/fsautocomplete.lua
Normal file
35
bundle/nvim-lspconfig/lua/lspconfig/fsautocomplete.lua
Normal file
@ -0,0 +1,35 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'fsautocomplete'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { 'dotnet', 'fsautocomplete', '--background-service-enabled' },
|
||||
root_dir = util.root_pattern('*.sln', '*.fsproj', '.git'),
|
||||
filetypes = { 'fsharp' },
|
||||
init_options = {
|
||||
AutomaticWorkspaceInit = true,
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/fsharp/FsAutoComplete
|
||||
|
||||
Language Server for F# provided by FsAutoComplete (FSAC).
|
||||
|
||||
FsAutoComplete requires the [dotnet-sdk](https://dotnet.microsoft.com/download) to be installed.
|
||||
|
||||
The preferred way to install FsAutoComplete is with `dotnet tool install --global fsautocomplete`.
|
||||
|
||||
Instructions to compile from source are found on the main [repository](https://github.com/fsharp/FsAutoComplete).
|
||||
|
||||
You may also need to configure the filetype as Vim defaults to Forth for `*.fs` files:
|
||||
|
||||
`autocmd BufNewFile,BufRead *.fs,*.fsx,*.fsi set filetype=fsharp`
|
||||
|
||||
This is automatically done by plugins such as [PhilT/vim-fsharp](https://github.com/PhilT/vim-fsharp), [fsharp/vim-fsharp](https://github.com/fsharp/vim-fsharp), and [adelarsq/neofsharp.vim](https://github.com/adelarsq/neofsharp.vim).
|
||||
|
||||
]],
|
||||
},
|
||||
}
|
22
bundle/nvim-lspconfig/lua/lspconfig/gdscript.lua
Normal file
22
bundle/nvim-lspconfig/lua/lspconfig/gdscript.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.gdscript = {
|
||||
default_config = {
|
||||
cmd = { 'nc', 'localhost', '6008' },
|
||||
filetypes = { 'gd', 'gdscript', 'gdscript3' },
|
||||
root_dir = util.root_pattern('project.godot', '.git'),
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/godotengine/godot
|
||||
|
||||
Language server for GDScript, used by Godot Engine.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[util.root_pattern("project.godot", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
22
bundle/nvim-lspconfig/lua/lspconfig/ghcide.lua
Normal file
22
bundle/nvim-lspconfig/lua/lspconfig/ghcide.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.ghcide = {
|
||||
default_config = {
|
||||
cmd = { 'ghcide', '--lsp' },
|
||||
filetypes = { 'haskell', 'lhaskell' },
|
||||
root_dir = util.root_pattern('stack.yaml', 'hie-bios', 'BUILD.bazel', 'cabal.config', 'package.yaml'),
|
||||
},
|
||||
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/digital-asset/ghcide
|
||||
|
||||
A library for building Haskell IDE tooling.
|
||||
"ghcide" isn't for end users now. Use "haskell-language-server" instead of "ghcide".
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("stack.yaml", "hie-bios", "BUILD.bazel", "cabal.config", "package.yaml")]],
|
||||
},
|
||||
},
|
||||
}
|
22
bundle/nvim-lspconfig/lua/lspconfig/gopls.lua
Normal file
22
bundle/nvim-lspconfig/lua/lspconfig/gopls.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.gopls = {
|
||||
default_config = {
|
||||
cmd = { 'gopls' },
|
||||
filetypes = { 'go', 'gomod' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern 'go.work'(fname) or util.root_pattern('go.mod', '.git')(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/golang/tools/tree/master/gopls
|
||||
|
||||
Google's lsp server for golang.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("go.mod", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
28
bundle/nvim-lspconfig/lua/lspconfig/graphql.lua
Normal file
28
bundle/nvim-lspconfig/lua/lspconfig/graphql.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'graphql'
|
||||
local bin_name = 'graphql-lsp'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, 'server', '-m', 'stream' },
|
||||
filetypes = { 'graphql' },
|
||||
root_dir = util.root_pattern('.git', '.graphqlrc*', '.graphql.config.*'),
|
||||
},
|
||||
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/graphql/graphiql/tree/main/packages/graphql-language-service-cli
|
||||
|
||||
`graphql-lsp` can be installed via `npm`:
|
||||
|
||||
```sh
|
||||
npm install -g graphql-language-service-cli
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern('.git', '.graphqlrc*', '.graphql.config.*')]],
|
||||
},
|
||||
},
|
||||
}
|
47
bundle/nvim-lspconfig/lua/lspconfig/groovyls.lua
Normal file
47
bundle/nvim-lspconfig/lua/lspconfig/groovyls.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local name = 'groovyls'
|
||||
local bin_name = 'groovy-language-server-all.jar'
|
||||
|
||||
configs[name] = {
|
||||
default_config = {
|
||||
cmd = {
|
||||
'java',
|
||||
'-jar',
|
||||
bin_name,
|
||||
},
|
||||
filetypes = { 'groovy' },
|
||||
root_dir = util.root_pattern '.git' or vim.loop.os_homedir(),
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/prominic/groovy-language-server.git
|
||||
|
||||
Requirements:
|
||||
- Linux/macOS (for now)
|
||||
- Java 11+
|
||||
|
||||
`groovyls` can be installed by following the instructions [here](https://github.com/prominic/groovy-language-server.git#build).
|
||||
|
||||
If you have installed groovy language server, you can set the `cmd` custom path as follow:
|
||||
|
||||
```lua
|
||||
require'lspconfig'.groovyls.setup{
|
||||
-- Unix
|
||||
cmd = { "java", "-jar", "path/to/groovyls/groovy-language-server-all.jar" },
|
||||
...
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
cmd = {
|
||||
'java',
|
||||
'-jar',
|
||||
bin_name,
|
||||
},
|
||||
filetypes = { 'groovy' },
|
||||
root_dir = [[root_pattern(".git") or vim.loop.os_homedir()]],
|
||||
},
|
||||
},
|
||||
}
|
48
bundle/nvim-lspconfig/lua/lspconfig/haxe_language_server.lua
Normal file
48
bundle/nvim-lspconfig/lua/lspconfig/haxe_language_server.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.haxe_language_server = {
|
||||
default_config = {
|
||||
cmd = { 'haxe-language-server' },
|
||||
filetypes = { 'haxe' },
|
||||
root_dir = util.root_pattern '*.hxml',
|
||||
settings = {
|
||||
haxe = {
|
||||
executable = 'haxe',
|
||||
},
|
||||
},
|
||||
init_options = {
|
||||
displayArguments = { 'build.hxml' },
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/vshaxe/haxe-language-server
|
||||
|
||||
The Haxe language server can be built by running the following commands from
|
||||
the project's root directory:
|
||||
|
||||
npm install
|
||||
npx lix run vshaxe-build -t language-server
|
||||
|
||||
This will create `bin/server.js`. Note that the server requires Haxe 3.4.0 or
|
||||
higher.
|
||||
|
||||
After building the language server, set the `cmd` setting in your setup
|
||||
function:
|
||||
|
||||
```lua
|
||||
lspconfig.haxe_language_server.setup({
|
||||
cmd = {"node", "path/to/bin/server.js"},
|
||||
})
|
||||
```
|
||||
|
||||
By default, an HXML compiler arguments file named `build.hxml` is expected in
|
||||
your project's root directory. If your file is named something different,
|
||||
specify it using the `init_options.displayArguments` setting.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("*.hxml")]],
|
||||
},
|
||||
},
|
||||
}
|
25
bundle/nvim-lspconfig/lua/lspconfig/health.lua
Normal file
25
bundle/nvim-lspconfig/lua/lspconfig/health.lua
Normal file
@ -0,0 +1,25 @@
|
||||
local M = {}
|
||||
function M.check_health()
|
||||
local configs = require 'lspconfig/configs'
|
||||
|
||||
for _, top_level_config in pairs(configs) do
|
||||
-- Only check configs that have a make_config function.
|
||||
if not (top_level_config.make_config == nil) then
|
||||
-- the folder needs to exist
|
||||
local config = top_level_config.make_config '.'
|
||||
|
||||
local status, cmd = pcall(vim.lsp._cmd_parts, config.cmd)
|
||||
if not status then
|
||||
vim.fn['health#report_error'](string.format('%s: config.cmd error, %s', config.name, cmd))
|
||||
else
|
||||
if not (vim.fn.executable(cmd) == 1) then
|
||||
vim.fn['health#report_error'](string.format('%s: The given command %q is not executable.', config.name, cmd))
|
||||
else
|
||||
vim.fn['health#report_info'](string.format('%s: configuration checked.', config.name))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
36
bundle/nvim-lspconfig/lua/lspconfig/hie.lua
Normal file
36
bundle/nvim-lspconfig/lua/lspconfig/hie.lua
Normal file
@ -0,0 +1,36 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.hie = {
|
||||
default_config = {
|
||||
cmd = { 'hie-wrapper', '--lsp' },
|
||||
filetypes = { 'haskell' },
|
||||
root_dir = util.root_pattern('stack.yaml', 'package.yaml', '.git'),
|
||||
},
|
||||
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/alanz/vscode-hie-server/master/package.json',
|
||||
description = [[
|
||||
https://github.com/haskell/haskell-ide-engine
|
||||
|
||||
the following init_options are supported (see https://github.com/haskell/haskell-ide-engine#configuration):
|
||||
```lua
|
||||
init_options = {
|
||||
languageServerHaskell = {
|
||||
hlintOn = bool;
|
||||
maxNumberOfProblems = number;
|
||||
diagnosticsDebounceDuration = number;
|
||||
liquidOn = bool (default false);
|
||||
completionSnippetsOn = bool (default true);
|
||||
formatOnImportOn = bool (default true);
|
||||
formattingProvider = string (default "brittany", alternate "floskell");
|
||||
}
|
||||
}
|
||||
```
|
||||
]],
|
||||
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("stack.yaml", "package.yaml", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
43
bundle/nvim-lspconfig/lua/lspconfig/hls.lua
Normal file
43
bundle/nvim-lspconfig/lua/lspconfig/hls.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.hls = {
|
||||
default_config = {
|
||||
cmd = { 'haskell-language-server-wrapper', '--lsp' },
|
||||
filetypes = { 'haskell', 'lhaskell' },
|
||||
root_dir = util.root_pattern('*.cabal', 'stack.yaml', 'cabal.project', 'package.yaml', 'hie.yaml'),
|
||||
settings = {
|
||||
haskell = {
|
||||
formattingProvider = 'ormolu',
|
||||
},
|
||||
},
|
||||
lspinfo = function(cfg)
|
||||
local extra = {}
|
||||
local function on_stdout(_, data, _)
|
||||
local version = data[1]
|
||||
table.insert(extra, 'version: ' .. version)
|
||||
end
|
||||
|
||||
local opts = {
|
||||
cwd = cfg.cwd,
|
||||
stdout_buffered = true,
|
||||
on_stdout = on_stdout,
|
||||
}
|
||||
local chanid = vim.fn.jobstart({ cfg.cmd[1], '--version' }, opts)
|
||||
vim.fn.jobwait { chanid }
|
||||
return extra
|
||||
end,
|
||||
},
|
||||
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/haskell/haskell-language-server
|
||||
|
||||
Haskell Language Server
|
||||
]],
|
||||
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml")]],
|
||||
},
|
||||
},
|
||||
}
|
43
bundle/nvim-lspconfig/lua/lspconfig/html.lua
Normal file
43
bundle/nvim-lspconfig/lua/lspconfig/html.lua
Normal file
@ -0,0 +1,43 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'html'
|
||||
local bin_name = 'vscode-html-language-server'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'html' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern('package.json', '.git')(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
settings = {},
|
||||
init_options = {
|
||||
embeddedLanguages = { css = true, javascript = true },
|
||||
configurationSection = { 'html', 'css', 'javascript' },
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
|
||||
`vscode-html-language-server` can be installed via `npm`:
|
||||
```sh
|
||||
npm i -g vscode-langservers-extracted
|
||||
```
|
||||
|
||||
Neovim does not currently include built-in snippets. `vscode-html-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'.html.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
42
bundle/nvim-lspconfig/lua/lspconfig/idris2_lsp.lua
Normal file
42
bundle/nvim-lspconfig/lua/lspconfig/idris2_lsp.lua
Normal file
@ -0,0 +1,42 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.idris2_lsp = {
|
||||
default_config = {
|
||||
cmd = { 'idris2-lsp' },
|
||||
filetypes = { 'idris2' },
|
||||
root_dir = util.root_pattern '*.ipkg',
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/idris-community/idris2-lsp
|
||||
|
||||
The Idris 2 language server.
|
||||
|
||||
Plugins for the Idris 2 filetype include
|
||||
[Idris2-Vim](https://github.com/edwinb/idris2-vim) (fewer features, stable) and
|
||||
[Nvim-Idris2](https://github.com/ShinKage/nvim-idris2) (cutting-edge,
|
||||
experimental).
|
||||
|
||||
Idris2-Lsp requires a build of Idris 2 that includes the "Idris 2 API" package.
|
||||
Package managers with known support for this build include the
|
||||
[AUR](https://aur.archlinux.org/packages/idris2-api-git/) and
|
||||
[Homebrew](https://formulae.brew.sh/formula/idris2#default).
|
||||
|
||||
If your package manager does not support the Idris 2 API, you will need to build
|
||||
Idris 2 from source. Refer to the
|
||||
[the Idris 2 installation instructions](https://github.com/idris-lang/Idris2/blob/main/INSTALL.md)
|
||||
for details. Steps 5 and 8 are listed as "optional" in that guide, but they are
|
||||
necessary in order to make the Idris 2 API available.
|
||||
|
||||
You need to install a version of Idris2-Lsp that is compatible with your
|
||||
version of Idris 2. There should be a branch corresponding to every released
|
||||
Idris 2 version after v0.4.0. Use the latest commit on that branch. For example,
|
||||
if you have Idris v0.5.1, you should use the v0.5.1 branch of Idris2-Lsp.
|
||||
|
||||
If your Idris 2 version is newer than the newest Idris2-Lsp branch, use the
|
||||
latest commit on the `master` branch, and set a reminder to check the Idris2-Lsp
|
||||
repo for the release of a compatible versioned branch.
|
||||
]],
|
||||
},
|
||||
}
|
48
bundle/nvim-lspconfig/lua/lspconfig/intelephense.lua
Normal file
48
bundle/nvim-lspconfig/lua/lspconfig/intelephense.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'intelephense'
|
||||
local bin_name = 'intelephense'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'php' },
|
||||
root_dir = function(pattern)
|
||||
local cwd = vim.loop.cwd()
|
||||
local root = util.root_pattern('composer.json', '.git')(pattern)
|
||||
|
||||
-- prefer cwd if root is a descendant
|
||||
return util.path.is_descendant(cwd, root) and cwd or root
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://intelephense.com/
|
||||
|
||||
`intelephense` can be installed via `npm`:
|
||||
```sh
|
||||
npm install -g intelephense
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
package_json = 'https://raw.githubusercontent.com/bmewburn/vscode-intelephense/master/package.json',
|
||||
root_dir = [[root_pattern("composer.json", ".git")]],
|
||||
init_options = [[{
|
||||
storagePath = Optional absolute path to storage dir. Defaults to os.tmpdir().
|
||||
globalStoragePath = Optional absolute path to a global storage dir. Defaults to os.homedir().
|
||||
licenceKey = Optional licence key or absolute path to a text file containing the licence key.
|
||||
clearCache = Optional flag to clear server state. State can also be cleared by deleting {storagePath}/intelephense
|
||||
-- See https://github.com/bmewburn/intelephense-docs/blob/master/installation.md#initialisation-options
|
||||
}]],
|
||||
settings = [[{
|
||||
intelephense = {
|
||||
files = {
|
||||
maxSize = 1000000;
|
||||
};
|
||||
};
|
||||
-- See https://github.com/bmewburn/intelephense-docs
|
||||
}]],
|
||||
},
|
||||
},
|
||||
}
|
22
bundle/nvim-lspconfig/lua/lspconfig/java_language_server.lua
Normal file
22
bundle/nvim-lspconfig/lua/lspconfig/java_language_server.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local lspconfig = require 'lspconfig'
|
||||
local configs = require 'lspconfig/configs'
|
||||
|
||||
local name = 'java_language_server'
|
||||
|
||||
configs[name] = {
|
||||
default_config = {
|
||||
filetypes = { 'java' },
|
||||
root_dir = lspconfig.util.root_pattern('build.gradle', 'pom.xml', '.git'),
|
||||
settings = {},
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/georgewfraser/java-language-server/master/package.json',
|
||||
description = [[
|
||||
https://github.com/georgewfraser/java-language-server
|
||||
|
||||
Java language server
|
||||
|
||||
Point `cmd` to `lang_server_linux.sh` or the equivalent script for macOS/Windows provided by java-language-server
|
||||
]],
|
||||
},
|
||||
}
|
193
bundle/nvim-lspconfig/lua/lspconfig/jdtls.lua
Normal file
193
bundle/nvim-lspconfig/lua/lspconfig/jdtls.lua
Normal file
@ -0,0 +1,193 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local handlers = require 'vim.lsp.handlers'
|
||||
|
||||
local server_name = 'jdtls'
|
||||
|
||||
local sysname = vim.loop.os_uname().sysname
|
||||
local env = {
|
||||
HOME = vim.loop.os_homedir(),
|
||||
JAVA_HOME = os.getenv 'JAVA_HOME',
|
||||
JDTLS_HOME = os.getenv 'JDTLS_HOME',
|
||||
WORKSPACE = os.getenv 'WORKSPACE',
|
||||
}
|
||||
|
||||
local function get_java_executable()
|
||||
local executable = env.JAVA_HOME and util.path.join(env.JAVA_HOME, 'bin', 'java') or 'java'
|
||||
|
||||
return sysname:match 'Windows' and executable .. '.exe' or executable
|
||||
end
|
||||
|
||||
local function get_workspace_dir()
|
||||
return env.WORKSPACE and env.WORKSPACE or util.path.join(env.HOME, 'workspace')
|
||||
end
|
||||
|
||||
local function get_jdtls_jar()
|
||||
return vim.fn.expand '$JDTLS_HOME/plugins/org.eclipse.equinox.launcher_*.jar'
|
||||
end
|
||||
|
||||
local function get_jdtls_config()
|
||||
if sysname:match 'Linux' then
|
||||
return util.path.join(env.JDTLS_HOME, 'config_linux')
|
||||
elseif sysname:match 'Darwin' then
|
||||
return util.path.join(env.JDTLS_HOME, 'config_mac')
|
||||
elseif sysname:match 'Windows' then
|
||||
return util.path.join(env.JDTLS_HOME, 'config_win')
|
||||
else
|
||||
return util.path.join(env.JDTLS_HOME, 'config_linux')
|
||||
end
|
||||
end
|
||||
|
||||
-- Non-standard notification that can be used to display progress
|
||||
local function on_language_status(_, _, result)
|
||||
local command = vim.api.nvim_command
|
||||
command 'echohl ModeMsg'
|
||||
command(string.format('echo "%s"', result.message))
|
||||
command 'echohl None'
|
||||
end
|
||||
|
||||
-- TextDocument version is reported as 0, override with nil so that
|
||||
-- the client doesn't think the document is newer and refuses to update
|
||||
-- See: https://github.com/eclipse/eclipse.jdt.ls/issues/1695
|
||||
local function fix_zero_version(workspace_edit)
|
||||
if workspace_edit and workspace_edit.documentChanges then
|
||||
for _, change in pairs(workspace_edit.documentChanges) do
|
||||
local text_document = change.textDocument
|
||||
if text_document and text_document.version and text_document.version == 0 then
|
||||
text_document.version = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
return workspace_edit
|
||||
end
|
||||
|
||||
local root_files = {
|
||||
-- Single-module projects
|
||||
{
|
||||
'build.xml', -- Ant
|
||||
'pom.xml', -- Maven
|
||||
'settings.gradle', -- Gradle
|
||||
'settings.gradle.kts', -- Gradle
|
||||
},
|
||||
-- Multi-module projects
|
||||
{ 'build.gradle', 'build.gradle.kts' },
|
||||
}
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = {
|
||||
get_java_executable(),
|
||||
'-Declipse.application=org.eclipse.jdt.ls.core.id1',
|
||||
'-Dosgi.bundles.defaultStartLevel=4',
|
||||
'-Declipse.product=org.eclipse.jdt.ls.core.product',
|
||||
'-Dlog.protocol=true',
|
||||
'-Dlog.level=ALL',
|
||||
'-Xms1g',
|
||||
'-Xmx2G',
|
||||
'-jar',
|
||||
get_jdtls_jar(),
|
||||
'-configuration',
|
||||
get_jdtls_config(),
|
||||
'-data',
|
||||
get_workspace_dir(),
|
||||
'--add-modules=ALL-SYSTEM',
|
||||
'--add-opens',
|
||||
'java.base/java.util=ALL-UNNAMED',
|
||||
'--add-opens',
|
||||
'java.base/java.lang=ALL-UNNAMED',
|
||||
},
|
||||
filetypes = { 'java' },
|
||||
root_dir = function(fname)
|
||||
for _, patterns in ipairs(root_files) do
|
||||
local root = util.root_pattern(unpack(patterns))(fname)
|
||||
if root then
|
||||
return root
|
||||
end
|
||||
end
|
||||
return vim.fn.getcwd()
|
||||
end,
|
||||
init_options = {
|
||||
workspace = get_workspace_dir(),
|
||||
jvm_args = {},
|
||||
os_config = nil,
|
||||
},
|
||||
handlers = {
|
||||
-- Due to an invalid protocol implementation in the jdtls we have to conform these to be spec compliant.
|
||||
-- https://github.com/eclipse/eclipse.jdt.ls/issues/376
|
||||
['textDocument/codeAction'] = function(a, b, actions)
|
||||
for _, action in ipairs(actions) do
|
||||
-- TODO: (steelsojka) Handle more than one edit?
|
||||
if action.command == 'java.apply.workspaceEdit' then -- 'action' is Command in java format
|
||||
action.edit = fix_zero_version(action.edit or action.arguments[1])
|
||||
elseif type(action.command) == 'table' and action.command.command == 'java.apply.workspaceEdit' then -- 'action' is CodeAction in java format
|
||||
action.edit = fix_zero_version(action.edit or action.command.arguments[1])
|
||||
end
|
||||
end
|
||||
handlers['textDocument/codeAction'](a, b, actions)
|
||||
end,
|
||||
|
||||
['textDocument/rename'] = function(a, b, workspace_edit)
|
||||
handlers['textDocument/rename'](a, b, fix_zero_version(workspace_edit))
|
||||
end,
|
||||
|
||||
['workspace/applyEdit'] = function(a, b, workspace_edit)
|
||||
handlers['workspace/applyEdit'](a, b, fix_zero_version(workspace_edit))
|
||||
end,
|
||||
|
||||
['language/status'] = vim.schedule_wrap(on_language_status),
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/redhat-developer/vscode-java/master/package.json',
|
||||
description = [[
|
||||
https://projects.eclipse.org/projects/eclipse.jdt.ls
|
||||
|
||||
Language server for Java.
|
||||
|
||||
IMPORTANT: If you want all the features jdtls has to offer, [nvim-jdtls](https://github.com/mfussenegger/nvim-jdtls)
|
||||
is highly recommended. If all you need is diagnostics, completion, imports, gotos and formatting and some code actions
|
||||
you can keep reading here.
|
||||
|
||||
For manual installation you can download precompiled binaries from the
|
||||
[official downloads site](http://download.eclipse.org/jdtls/snapshots/?d)
|
||||
|
||||
Due to the nature of java, settings cannot be inferred. Please set the following
|
||||
environmental variables to match your installation. If you need per-project configuration
|
||||
[direnv](https://github.com/direnv/direnv) is highly recommended.
|
||||
|
||||
```bash
|
||||
# Mandatory:
|
||||
# .bashrc
|
||||
export JDTLS_HOME=/path/to/jdtls_root # Directory with the plugin and configs directories
|
||||
|
||||
# Optional:
|
||||
export JAVA_HOME=/path/to/java_home # In case you don't have java in path or want to use a version in particular
|
||||
export WORKSPACE=/path/to/workspace # Defaults to $HOME/workspace
|
||||
```
|
||||
```lua
|
||||
-- init.lua
|
||||
require'lspconfig'.jdtls.setup{}
|
||||
```
|
||||
|
||||
For automatic installation you can use the following unofficial installers/launchers under your own risk:
|
||||
- [jdtls-launcher](https://github.com/eruizc-dev/jdtls-launcher) (Includes lombok support by default)
|
||||
```lua
|
||||
-- init.lua
|
||||
require'lspconfig'.jdtls.setup{ cmd = { 'jdtls' } }
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[{
|
||||
-- Single-module projects
|
||||
{
|
||||
'build.xml', -- Ant
|
||||
'pom.xml', -- Maven
|
||||
'settings.gradle', -- Gradle
|
||||
'settings.gradle.kts', -- Gradle
|
||||
},
|
||||
-- Multi-module projects
|
||||
{ 'build.gradle', 'build.gradle.kts' },
|
||||
} or vim.fn.getcwd()]],
|
||||
},
|
||||
},
|
||||
}
|
21
bundle/nvim-lspconfig/lua/lspconfig/jedi_language_server.lua
Normal file
21
bundle/nvim-lspconfig/lua/lspconfig/jedi_language_server.lua
Normal file
@ -0,0 +1,21 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
|
||||
configs.jedi_language_server = {
|
||||
default_config = {
|
||||
cmd = { 'jedi-language-server' },
|
||||
filetypes = { 'python' },
|
||||
root_dir = function(fname)
|
||||
return vim.fn.getcwd()
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/pappasam/jedi-language-server
|
||||
|
||||
`jedi-language-server`, a language server for Python, built on top of jedi
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = "vim's starting directory",
|
||||
},
|
||||
},
|
||||
}
|
61
bundle/nvim-lspconfig/lua/lspconfig/jsonls.lua
Normal file
61
bundle/nvim-lspconfig/lua/lspconfig/jsonls.lua
Normal file
@ -0,0 +1,61 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'jsonls'
|
||||
local bin_name = 'vscode-json-language-server'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'json' },
|
||||
init_options = {
|
||||
provideFormatter = true,
|
||||
},
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern '.git'(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
-- this language server config is in VSCode built-in package.json
|
||||
package_json = 'https://raw.githubusercontent.com/microsoft/vscode/master/extensions/json-language-features/package.json',
|
||||
description = [[
|
||||
https://github.com/hrsh7th/vscode-langservers-extracted
|
||||
|
||||
vscode-json-language-server, a language server for JSON and JSON schema
|
||||
|
||||
`vscode-json-language-server` can be installed via `npm`:
|
||||
```sh
|
||||
npm i -g vscode-langservers-extracted
|
||||
```
|
||||
|
||||
vscode-json-language-server only provides range formatting. You can map a command that applies range formatting to the entire document:
|
||||
|
||||
```lua
|
||||
require'lspconfig'.jsonls.setup {
|
||||
commands = {
|
||||
Format = {
|
||||
function()
|
||||
vim.lsp.buf.range_formatting({},{0,0},{vim.fn.line("$"),0})
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Neovim does not currently include built-in snippets. `vscode-json-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'.jsonls.setup {
|
||||
capabilities = capabilities,
|
||||
}
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern(".git") or dirname]],
|
||||
},
|
||||
},
|
||||
}
|
79
bundle/nvim-lspconfig/lua/lspconfig/julials.lua
Normal file
79
bundle/nvim-lspconfig/lua/lspconfig/julials.lua
Normal file
@ -0,0 +1,79 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local cmd = {
|
||||
'julia',
|
||||
'--startup-file=no',
|
||||
'--history-file=no',
|
||||
'-e',
|
||||
[[
|
||||
# Load LanguageServer.jl: attempt to load from ~/.julia/environments/nvim-lspconfig
|
||||
# with the regular load path as a fallback
|
||||
ls_install_path = joinpath(
|
||||
get(DEPOT_PATH, 1, joinpath(homedir(), ".julia")),
|
||||
"environments", "nvim-lspconfig"
|
||||
)
|
||||
pushfirst!(LOAD_PATH, ls_install_path)
|
||||
using LanguageServer
|
||||
popfirst!(LOAD_PATH)
|
||||
depot_path = get(ENV, "JULIA_DEPOT_PATH", "")
|
||||
project_path = let
|
||||
dirname(something(
|
||||
## 1. Finds an explicitly set project (JULIA_PROJECT)
|
||||
Base.load_path_expand((
|
||||
p = get(ENV, "JULIA_PROJECT", nothing);
|
||||
p === nothing ? nothing : isempty(p) ? nothing : p
|
||||
)),
|
||||
## 2. Look for a Project.toml file in the current working directory,
|
||||
## or parent directories, with $HOME as an upper boundary
|
||||
Base.current_project(),
|
||||
## 3. First entry in the load path
|
||||
get(Base.load_path(), 1, nothing),
|
||||
## 4. Fallback to default global environment,
|
||||
## this is more or less unreachable
|
||||
Base.load_path_expand("@v#.#"),
|
||||
))
|
||||
end
|
||||
@info "Running language server" VERSION pwd() project_path depot_path
|
||||
server = LanguageServer.LanguageServerInstance(stdin, stdout, project_path, depot_path)
|
||||
server.runlinter = true
|
||||
run(server)
|
||||
]],
|
||||
}
|
||||
|
||||
configs.julials = {
|
||||
default_config = {
|
||||
cmd = cmd,
|
||||
on_new_config = function(new_config, root_dir)
|
||||
new_config.cmd_cwd = root_dir
|
||||
end,
|
||||
filetypes = { 'julia' },
|
||||
root_dir = function(fname)
|
||||
return util.find_git_ancestor(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/julia-vscode/julia-vscode/master/package.json',
|
||||
description = [[
|
||||
https://github.com/julia-vscode/julia-vscode
|
||||
|
||||
LanguageServer.jl can be installed with `julia` and `Pkg`:
|
||||
```sh
|
||||
julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.add("LanguageServer")'
|
||||
```
|
||||
where `~/.julia/environments/nvim-lspconfig` is the location where
|
||||
the default configuration expects LanguageServer.jl to be installed.
|
||||
|
||||
To update an existing install, use the following command:
|
||||
```sh
|
||||
julia --project=~/.julia/environments/nvim-lspconfig -e 'using Pkg; Pkg.update()'
|
||||
```
|
||||
|
||||
Note: In order to have LanguageServer.jl pick up installed packages or dependencies in a
|
||||
Julia project, you must make sure that the project is instantiated:
|
||||
```sh
|
||||
julia --project=/path/to/my/project -e 'using Pkg; Pkg.instantiate()'
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
--- default config for gradle-projects of the
|
||||
--- kotlin-language-server: https://github.com/fwcd/kotlin-language-server
|
||||
---
|
||||
--- This server requires vim to be aware of the kotlin-filetype.
|
||||
--- You could refer for this capability to:
|
||||
--- https://github.com/udalov/kotlin-vim (recommended)
|
||||
--- Note that there is no LICENSE specified yet.
|
||||
|
||||
local util = require 'lspconfig/util'
|
||||
local configs = require 'lspconfig/configs'
|
||||
|
||||
local bin_name = 'kotlin-language-server'
|
||||
if vim.fn.has 'win32' == 1 then
|
||||
bin_name = bin_name .. '.bat'
|
||||
end
|
||||
|
||||
--- The presence of one of these files indicates a project root directory
|
||||
--
|
||||
-- These are configuration files for the various build systems supported by
|
||||
-- Kotlin. I am not sure whether the language server supports Ant projects,
|
||||
-- but I'm keeping it here as well since Ant does support Kotlin.
|
||||
local root_files = {
|
||||
'settings.gradle', -- Gradle (multi-project)
|
||||
'settings.gradle.kts', -- Gradle (multi-project)
|
||||
'build.xml', -- Ant
|
||||
'pom.xml', -- Maven
|
||||
}
|
||||
|
||||
local fallback_root_files = {
|
||||
'build.gradle', -- Gradle
|
||||
'build.gradle.kts', -- Gradle
|
||||
}
|
||||
|
||||
configs.kotlin_language_server = {
|
||||
default_config = {
|
||||
filetypes = { 'kotlin' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern(unpack(root_files))(fname) or util.root_pattern(unpack(fallback_root_files))(fname)
|
||||
end,
|
||||
cmd = { bin_name },
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/fwcd/vscode-kotlin/master/package.json',
|
||||
description = [[
|
||||
A kotlin language server which was developed for internal usage and
|
||||
released afterwards. Maintaining is not done by the original author,
|
||||
but by fwcd.
|
||||
|
||||
It is built via gradle and developed on github.
|
||||
Source and additional description:
|
||||
https://github.com/fwcd/kotlin-language-server
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("settings.gradle")]],
|
||||
cmd = { 'kotlin-language-server' },
|
||||
capabilities = [[
|
||||
smart code completion,
|
||||
diagnostics,
|
||||
hover,
|
||||
document symbols,
|
||||
definition lookup,
|
||||
method signature help,
|
||||
dependency resolution,
|
||||
additional plugins from: https://github.com/fwcd
|
||||
|
||||
Snipped of License (refer to source for full License):
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 George Fraser
|
||||
Copyright (c) 2018 fwcd
|
||||
|
||||
]],
|
||||
},
|
||||
},
|
||||
}
|
50
bundle/nvim-lspconfig/lua/lspconfig/lean3ls.lua
Normal file
50
bundle/nvim-lspconfig/lua/lspconfig/lean3ls.lua
Normal file
@ -0,0 +1,50 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.lean3ls = {
|
||||
default_config = {
|
||||
cmd = { 'lean-language-server', '--stdio', '--', '-M', '4096', '-T', '100000' },
|
||||
filetypes = { 'lean3' },
|
||||
root_dir = function(fname)
|
||||
-- check if inside elan stdlib
|
||||
local stdlib_dir
|
||||
do
|
||||
local _, endpos = fname:find(util.path.sep .. util.path.join('lean', 'library'))
|
||||
if endpos then
|
||||
stdlib_dir = fname:sub(1, endpos)
|
||||
end
|
||||
end
|
||||
|
||||
return util.root_pattern 'leanpkg.toml'(fname)
|
||||
or util.root_pattern 'leanpkg.path'(fname)
|
||||
or stdlib_dir
|
||||
or util.find_git_ancestor(fname)
|
||||
or util.path.dirname(fname)
|
||||
end,
|
||||
on_new_config = function(config, root)
|
||||
if not config.cmd_cwd then
|
||||
config.cmd_cwd = root
|
||||
end
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/leanprover/lean-client-js/tree/master/lean-language-server
|
||||
|
||||
Lean installation instructions can be found
|
||||
[here](https://leanprover-community.github.io/get_started.html#regular-install).
|
||||
|
||||
Once Lean is installed, you can install the Lean 3 language server by running
|
||||
```sh
|
||||
npm install -g lean-language-server
|
||||
```
|
||||
|
||||
Note: that if you're using [lean.nvim](https://github.com/Julian/lean.nvim),
|
||||
that plugin fully handles the setup of the Lean language server,
|
||||
and you shouldn't set up `lean3ls` both with it and `lspconfig`.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]],
|
||||
},
|
||||
},
|
||||
}
|
47
bundle/nvim-lspconfig/lua/lspconfig/leanls.lua
Normal file
47
bundle/nvim-lspconfig/lua/lspconfig/leanls.lua
Normal file
@ -0,0 +1,47 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.leanls = {
|
||||
default_config = {
|
||||
cmd = { 'lean', '--server' },
|
||||
filetypes = { 'lean' },
|
||||
root_dir = function(fname)
|
||||
-- check if inside elan stdlib
|
||||
local stdlib_dir
|
||||
do
|
||||
local _, endpos = fname:find(util.path.sep .. util.path.join('lib', 'lean'))
|
||||
if endpos then
|
||||
stdlib_dir = fname:sub(1, endpos)
|
||||
end
|
||||
end
|
||||
|
||||
return util.root_pattern 'leanpkg.toml'(fname)
|
||||
or stdlib_dir
|
||||
or util.find_git_ancestor(fname)
|
||||
or util.path.dirname(fname)
|
||||
end,
|
||||
on_new_config = function(config, root)
|
||||
if not config.cmd_cwd then
|
||||
config.cmd_cwd = root
|
||||
end
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/leanprover/lean4
|
||||
|
||||
Lean installation instructions can be found
|
||||
[here](https://leanprover-community.github.io/get_started.html#regular-install).
|
||||
|
||||
The Lean 4 language server is built-in with a Lean 4 install
|
||||
(and can be manually run with, e.g., `lean --server`).
|
||||
|
||||
Note: that if you're using [lean.nvim](https://github.com/Julian/lean.nvim),
|
||||
that plugin fully handles the setup of the Lean language server,
|
||||
and you shouldn't set up `leanls` both with it and `lspconfig`.
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("leanpkg.toml") or root_pattern(".git") or path.dirname]],
|
||||
},
|
||||
},
|
||||
}
|
32
bundle/nvim-lspconfig/lua/lspconfig/lemminx.lua
Normal file
32
bundle/nvim-lspconfig/lua/lspconfig/lemminx.lua
Normal file
@ -0,0 +1,32 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'lemminx'
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
filetypes = { 'xml', 'xsd', 'svg' },
|
||||
root_dir = function(filename)
|
||||
return util.root_pattern '.git'(filename) or util.path.dirname(filename)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/eclipse/lemminx
|
||||
|
||||
The easiest way to install the server is to get a binary at https://download.jboss.org/jbosstools/vscode/stable/lemminx-binary/ and place it in your PATH.
|
||||
|
||||
**By default, lemminx doesn't have a `cmd` set.** This is because nvim-lspconfig does not make assumptions about your path. You must add the following to your init.vim or init.lua to set `cmd` to the absolute path ($HOME and ~ are not expanded) of your unzipped lemminx.
|
||||
|
||||
```lua
|
||||
require'lspconfig'.lemminx.setup{
|
||||
cmd = { "/path/to/lemminx/lemminx" };
|
||||
...
|
||||
}
|
||||
|
||||
NOTE to macOS users: Binaries from unidentified developers are blocked by default. If you trust the downloaded binary from jboss.org, run it once, cancel the prompt, then remove the binary from Gatekeeper quarantine with `xattr -d com.apple.quarantine lemminx`. It should now run without being blocked.
|
||||
|
||||
]],
|
||||
},
|
||||
}
|
||||
|
||||
-- vim:et ts=2 sw=2
|
48
bundle/nvim-lspconfig/lua/lspconfig/metals.lua
Normal file
48
bundle/nvim-lspconfig/lua/lspconfig/metals.lua
Normal file
@ -0,0 +1,48 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
local server_name = 'metals'
|
||||
local bin_name = 'metals'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name },
|
||||
filetypes = { 'scala' },
|
||||
root_dir = util.root_pattern('build.sbt', 'build.sc', 'build.gradle', 'pom.xml'),
|
||||
message_level = vim.lsp.protocol.MessageType.Log,
|
||||
init_options = {
|
||||
statusBarProvider = 'show-message',
|
||||
isHttpEnabled = true,
|
||||
compilerOptions = {
|
||||
snippetAutoIndent = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://scalameta.org/metals/
|
||||
|
||||
Scala language server with rich IDE features.
|
||||
|
||||
See full instructions in the Metals documentation:
|
||||
|
||||
https://scalameta.org/metals/docs/editors/vim.html#using-an-alternative-lsp-client
|
||||
|
||||
Note: that if you're using [nvim-metals](https://github.com/scalameta/nvim-metals), that plugin fully handles the setup and installation of Metals, and you shouldn't set up Metals both with it and `lspconfig`.
|
||||
|
||||
To install Metals, make sure to have [coursier](https://get-coursier.io/docs/cli-installation) installed, and once you do you can install the latest Metals with `cs install metals`. You can also manually bootstrap Metals with the following command.
|
||||
|
||||
```bash
|
||||
cs bootstrap \
|
||||
--java-opt -Xss4m \
|
||||
--java-opt -Xms100m \
|
||||
org.scalameta:metals_2.12:<enter-version-here> \
|
||||
-r bintray:scalacenter/releases \
|
||||
-r sonatype:snapshots \
|
||||
-o /usr/local/bin/metals -f
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[util.root_pattern("build.sbt", "build.sc", "build.gradle", "pom.xml")]],
|
||||
},
|
||||
},
|
||||
}
|
20
bundle/nvim-lspconfig/lua/lspconfig/mint.lua
Normal file
20
bundle/nvim-lspconfig/lua/lspconfig/mint.lua
Normal file
@ -0,0 +1,20 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.mint = {
|
||||
default_config = {
|
||||
cmd = { 'mint', 'ls' },
|
||||
filetypes = { 'mint' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern 'mint.json'(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://www.mint-lang.com
|
||||
|
||||
Install Mint using the [instructions](https://www.mint-lang.com/install).
|
||||
The language server is included since version 0.12.0.
|
||||
]],
|
||||
},
|
||||
}
|
22
bundle/nvim-lspconfig/lua/lspconfig/nimls.lua
Normal file
22
bundle/nvim-lspconfig/lua/lspconfig/nimls.lua
Normal file
@ -0,0 +1,22 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
configs.nimls = {
|
||||
default_config = {
|
||||
cmd = { 'nimlsp' },
|
||||
filetypes = { 'nim' },
|
||||
root_dir = function(fname)
|
||||
return util.root_pattern '*.nimble'(fname) or util.find_git_ancestor(fname) or util.path.dirname(fname)
|
||||
end,
|
||||
},
|
||||
docs = {
|
||||
package_json = 'https://raw.githubusercontent.com/pragmagic/vscode-nim/master/package.json',
|
||||
description = [[
|
||||
https://github.com/PMunch/nimlsp
|
||||
`nimlsp` can be installed via the `nimble` package manager:
|
||||
```sh
|
||||
nimble install nimlsp
|
||||
```
|
||||
]],
|
||||
},
|
||||
}
|
26
bundle/nvim-lspconfig/lua/lspconfig/ocamlls.lua
Normal file
26
bundle/nvim-lspconfig/lua/lspconfig/ocamlls.lua
Normal file
@ -0,0 +1,26 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local server_name = 'ocamlls'
|
||||
local bin_name = 'ocaml-language-server'
|
||||
|
||||
configs[server_name] = {
|
||||
default_config = {
|
||||
cmd = { bin_name, '--stdio' },
|
||||
filetypes = { 'ocaml', 'reason' },
|
||||
root_dir = util.root_pattern('*.opam', 'esy.json', 'package.json'),
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/ocaml-lsp/ocaml-language-server
|
||||
|
||||
`ocaml-language-server` can be installed via `npm`
|
||||
```sh
|
||||
npm install -g ocaml-langauge-server
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("*.opam", "esy.json", "package.json")]],
|
||||
},
|
||||
},
|
||||
}
|
39
bundle/nvim-lspconfig/lua/lspconfig/ocamllsp.lua
Normal file
39
bundle/nvim-lspconfig/lua/lspconfig/ocamllsp.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local configs = require 'lspconfig/configs'
|
||||
local util = require 'lspconfig/util'
|
||||
|
||||
local language_id_of = {
|
||||
menhir = 'ocaml.menhir',
|
||||
ocaml = 'ocaml',
|
||||
ocamlinterface = 'ocaml.interface',
|
||||
ocamllex = 'ocaml.ocamllex',
|
||||
reason = 'reason',
|
||||
}
|
||||
|
||||
local get_language_id = function(_, ftype)
|
||||
return language_id_of[ftype]
|
||||
end
|
||||
|
||||
configs.ocamllsp = {
|
||||
default_config = {
|
||||
cmd = { 'ocamllsp' },
|
||||
filetypes = { 'ocaml', 'ocaml.menhir', 'ocaml.interface', 'ocaml.ocamllex', 'reason' },
|
||||
root_dir = util.root_pattern('*.opam', 'esy.json', 'package.json', '.git'),
|
||||
get_language_id = get_language_id,
|
||||
},
|
||||
docs = {
|
||||
description = [[
|
||||
https://github.com/ocaml/ocaml-lsp
|
||||
|
||||
`ocaml-lsp` can be installed as described in [installation guide](https://github.com/ocaml/ocaml-lsp#installation).
|
||||
|
||||
To install the lsp server in a particular opam switch:
|
||||
```sh
|
||||
opam pin add ocaml-lsp-server https://github.com/ocaml/ocaml-lsp.git
|
||||
opam install ocaml-lsp-server
|
||||
```
|
||||
]],
|
||||
default_config = {
|
||||
root_dir = [[root_pattern("*.opam", "esy.json", "package.json", ".git")]],
|
||||
},
|
||||
},
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user