Comments (7)
You can handle them capabilities like below (without any modifications).
function! s:on_lsp_buffer_enabled() abort
let l:capabilities = lsp#get_server_capabilities('pyright-langserver')
if !empty(l:capabilities)
let l:capabilities.definitionProvider = v:false
let l:capabilities.declarationProvider = v:false
let l:capabilities.referencesProvider = v:false
endif
endfunction
augroup vim-lsp
au!
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
from vim-lsp.
Added an additional option in the fork here https://github.com/sullivan-sean/vim-lsp to override the lsp#get_server_capabilities
function. It also exposes the default implementation of this function so that you can modify the capabilities that are returned from the init request.
It returns an object that is internal to vim-lsp
so it's best to deepcopy when overriding this function if you plan to mutate in a way that matters.
Here is what I have in my .vimrc
using the fork to disable certain capabilities to avoid clashing goto actions:
function! s:get_server_capabilities(server_name) abort
let l:capabilities = deepcopy(lsp#default_get_server_capabilities(a:server_name))
" Disable links for pyright langserver to avoid duplicate entries
if a:server_name ==# 'pyright-langserver'
for l:key in ['definitionProvider', 'declarationProvider', 'referencesProvider']
if has_key(l:capabilities, l:key)
call remove(l:capabilities, l:key)
endif
endfor
endif
return l:capabilities
endfunction
let g:lsp_get_server_capabilities = [function('s:get_server_capabilities')]
from vim-lsp.
Very happy to upstream some variation of this if you'd like to support this kind of functionality @prabirshrestha
from vim-lsp.
Thank you for working on this! I will try later to see if this fits my needs.
from vim-lsp.
Even better! thanks
from vim-lsp.
Thank you and even without changes!
from vim-lsp.
@mattn I just tried your proposed solution like this:
if executable('pylsp')
" pip install python-language-server
au User lsp_setup call lsp#register_server({
\ 'name': 'pylsp',
\ 'cmd': {server_info->['pylsp']},
\ 'allowlist': ['python'],
\ 'workspace_config': {'pylsp': {'plugins':
\ {'pycodestyle': {'maxLineLength': 88}}
\ }},
\ })
endif
function! s:on_lsp_buffer_enabled() abort
setlocal signcolumn=yes
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif
nmap <buffer> gd <plug>(lsp-definition)
nmap <buffer> gr <plug>(lsp-references)
nmap <buffer> gi <plug>(lsp-implementation)
nmap <buffer> gt <plug>(lsp-type-definition)
nmap <buffer> <leader>rn <plug>(lsp-rename)
nmap <buffer> [g <plug>(lsp-previous-diagnostic)
nmap <buffer> ]g <plug>(lsp-next-diagnostic)
nmap <buffer> K <plug>(lsp-hover)
nmap <buffer> <leader>df <plug>(lsp-document-format)
nmap <buffer> <leader>ca <plug>(lsp-code-action)
let g:BASH_Ctrl_j = 'off'
inoremap <buffer> <expr><c-j> lsp#scroll(+4)
inoremap <buffer> <expr><c-k> lsp#scroll(-4)
nnoremap <buffer> <expr><c-j> lsp#scroll(+4)
nnoremap <buffer> <expr><c-k> lsp#scroll(-4)
" refer to doc to add more commands
endfunction
augroup vim-lsp
au!
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
function! s:on_lsp_buffer_enabled() abort
let l:capabilities = lsp#get_server_capabilities('pylsp')
if !empty(l:capabilities)
let l:capabilities.diagnosticProvider = v:false
endif
endfunction
augroup lsp_install
au!
" call s:on_lsp_buffer_enabled only for languages that has the server registered.
autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled()
augroup END
However, I still get diagnostics from pylsp. I tried to put the solution you proposed at different position in the config but this did not help. What did I get wrong?
from vim-lsp.
Related Issues (20)
- Get LSP to work with complicated Scala project with git submodules. HOT 1
- Undo in neovim HOT 1
- LSP Workspace Diagnostics
- LSP servers not connecting, Windows 11 HOT 1
- File ownership state is out of sync when doing multiple LspRename on unsaved buffers on multiple files HOT 1
- Restart the lsp server can not work.
- Bug: Updating buffer (open, reload) creates duplicated server-side content when multiple LSP servers are enabled HOT 1
- [Feature request] Install `python-lsp-ruff` plugin with `:LspInstallServer` HOT 1
- LspStopServer only works for a few seconds, server auto-starts
- hope vimlsp recognize progress info
- Diagnostics display as line until hovered? HOT 1
- bug info vim-lsp
- Prettier & ESLint HOT 1
- Text edits with the same start position are applied in reverse HOT 2
- Checking if LSP server is running for a specific filetype
- cursorline and cursor messed up with vim-lsp.
- Add some way to disable diagnostics from a given server
- didChange event removing all contents when closing window shortly after a change HOT 1
- How do you remove the underlines? HOT 3
- vim lsp causing huge slow down on large C++ file
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-lsp.