Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

async language server protocol plugin for vim and neovim

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-THIRD-PARTY
NotificationsYou must be signed in to change notification settings

prabirshrestha/vim-lsp

Repository files navigation

AsyncLanguage Server Protocol plugin for vim8 and neovim.

Installing

Installvim-plug and then:

Plug'prabirshrestha/vim-lsp'

Performance

Certain bottlenecks in Vim script have been implemented in lua. If you would like to take advantage of these performance gainsuse vim compiled with lua or neovim v0.4.0+

Registering servers

ifexecutable('pylsp')" pip install python-lsp-serverauUserlsp_setupcalllsp#register_server({\'name':'pylsp',\'cmd': {server_info->['pylsp']},\'allowlist': ['python'],\})endiffunction!s:on_lsp_buffer_enabled()abortsetlocalomnifunc=lsp#completesetlocalsigncolumn=yesifexists('+tagfunc') |setlocaltagfunc=lsp#tagfunc |endifnmap<buffer>gd<plug>(lsp-definition)nmap<buffer>gs<plug>(lsp-document-symbol-search)nmap<buffer>gS<plug>(lsp-workspace-symbol-search)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)nnoremap<buffer><expr><c-f>lsp#scroll(+4)nnoremap<buffer><expr><c-d>lsp#scroll(-4)letg:lsp_format_sync_timeout=1000autocmd!BufWritePre*.rs,*.gocallexecute('LspDocumentFormatSync')" refer to doc to add more commandsendfunctionaugrouplsp_installau!" call s:on_lsp_buffer_enabled only for languages that has the server registered.autocmdUserlsp_buffer_enabledcalls:on_lsp_buffer_enabled()augroupEND

Refer tovim-lsp-settings on how to easily setup language servers using vim-lsp automatically.

Plug'prabirshrestha/vim-lsp'Plug'mattn/vim-lsp-settings'

auto-complete

Refer to docs on configuring omnifunc orasyncomplete.vim.

Snippets

vim-lsp does not support snippets by default. If you want snippet integration, you will first have to install a third-party snippet plugin and a plugin that integrates it in vim-lsp.At the moment, you have following options:

  1. vim-vsnip together withvim-vsnip-integ
  2. UltiSnips together withvim-lsp-ultisnips
  3. neosnippet.vim together withvim-lsp-neosnippet

For more information, refer to the readme and documentation of the respective plugins.

Folding

You can let the language server automatically handle folding for you. To enable this, you have to set'foldmethod','foldexpr' and (optionally)'foldtext':

setfoldmethod=expr\foldexpr=lsp#ui#vim#folding#foldexpr()\foldtext=lsp#ui#vim#folding#foldtext()

If you would like to disable folding globally, you can add this to your configuration:

letg:lsp_fold_enabled=0

Also see:h vim-lsp-folding.

Semantic highlighting

vim-lsp supports the unofficial extension to the LSP protocol for semantic highlighting (microsoft/vscode-languageserver-node#367).This feature requires Neovim highlights, or Vim with thetextprop feature enabled.You will also need to link language server semantic scopes to Vim highlight groups.Refer to:h vim-lsp-semantic for more info.

Supported commands

Note:

  • Some servers may only support partial commands.
  • While it is possible to register multiple servers for the same filetype, some commands will pick only the first server that supports it. For example, it doesn't make sense for rename and format commands to be sent to multiple servers.
CommandDescription
:LspAddTreeCallHierarchyIncomingFind incoming call hierarchy for the symbol under cursor, but add the result to the current list
:LspCallHierarchyIncomingFind incoming call hierarchy for the symbol under cursor
:LspCallHierarchyOutgoingFind outgoing call hierarchy for the symbol under cursor
:LspCodeActionGets a list of possible commands that can be applied to a file so it can be fixed (quick fix)
:LspCodeLensGets a list of possible commands that can be executed on the current document
:LspDeclarationGo to the declaration of the word under the cursor, and open in the current window
:LspDefinitionGo to the definition of the word under the cursor, and open in the current window
:LspDocumentDiagnosticsGet current document diagnostics information
:LspDocumentFormatFormat entire document
:LspDocumentRangeFormatFormat document selection
:LspDocumentSymbolShow document symbols
:LspHoverShow hover information
:LspImplementationShow implementation of interface in the current window
:LspNextDiagnosticjump to next diagnostic (all of error, warning, information, hint)
:LspNextErrorjump to next error
:LspNextReferencejump to next reference to the symbol under cursor
:LspNextWarningjump to next warning
:LspPeekDeclarationGo to the declaration of the word under the cursor, but open in preview window
:LspPeekDefinitionGo to the definition of the word under the cursor, but open in preview window
:LspPeekImplementationGo to the implementation of an interface, but open in preview window
:LspPeekTypeDefinitionGo to the type definition of the word under the cursor, but open in preview window
:LspPreviousDiagnosticjump to previous diagnostic (all of error, warning, information, hint)
:LspPreviousErrorjump to previous error
:LspPreviousReferencejump to previous reference to the symbol under cursor
:LspPreviousWarningjump to previous warning
:LspReferencesFind references
:LspRenameRename symbol
:LspStatusShow the status of the language server
:LspTypeDefinitionGo to the type definition of the word under the cursor, and open in the current window
:LspTypeHierarchyView type hierarchy of the symbol under the cursor
:LspWorkspaceSymbolSearch/Show workspace symbol

Diagnostics

Document diagnostics (e.g. warnings, errors) are enabled by default, but if youpreferred to turn them off and use other plugins instead (likeNeomake orALE, setg:lsp_diagnostics_enabled to0:

letg:lsp_diagnostics_enabled=0" disable diagnostics support

Highlight references

Highlight references to the symbol under the cursor (enabled by default).You can disable it by adding

letg:lsp_document_highlight_enabled=0

to your configuration.

To change the style of the highlighting, you can set or link thelspReferencehighlight group, e.g.:

highlight lspReference ctermfg=red guifg=red ctermbg=green guibg=green

Debugging

In order to enable file logging setg:lsp_log_file.

letg:lsp_log_verbose=1letg:lsp_log_file=expand('~/vim-lsp.log')" for asyncomplete.vim logletg:asyncomplete_log_file=expand('~/asyncomplete.log')

You can get detailed status on your servers using:CheckHealth with a plugin on vim:

if!has('nvim') | Plug'rhysd/vim-healthcheck' |endifCheckHealth

Tests

vim-themis is used for testing. To runintegration testsgoplsexecutable must be in path.

Maintainers

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]

About

async language server protocol plugin for vim and neovim

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE-THIRD-PARTY

Stars

Watchers

Forks

Packages

No packages published

Contributors170

Languages


[8]ページ先頭

©2009-2025 Movatter.jp