Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/hrsh7th/vim-lamp

💡Language Server Protocol client for Vim.
https://github.com/hrsh7th/vim-lamp

language-server-protocol lsp nvim nvim-plugin vim vim-plugin

Last synced: about 2 months ago
JSON representation

💡Language Server Protocol client for Vim.

Awesome Lists containing this project

README

        

# vim-lamp
Language Server Protocol client for Vim.

# Concept
- Works on vim/nvim both
- High performance
- Well supported LSP spec
- Well visualize diagnostics

# Status
- APIs aren't stable yet.
- Apply breaking change with no announcement.

# Setting

```vim
if has('vim_starting')
set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
set nocompatible
endif

if !isdirectory(expand('~/.vim/plugged/vim-plug'))
silent !curl -fLo ~/.vim/plugged/vim-plug/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
end
execute printf('source %s', expand('~/.vim/plugged/vim-plug/plug.vim'))

call plug#begin('~/.vim/plugged')
Plug 'hrsh7th/vim-lamp'
Plug 'hrsh7th/vim-compete'
Plug 'hrsh7th/vim-compete-lamp'
Plug 'hrsh7th/vim-vsnip'
Plug 'hrsh7th/vim-vsnip-integ'
call plug#end()

"
" required options
"
set hidden

augroup vimrc
autocmd!
augroup END

"
" initialize servers
"
autocmd! vimrc User lamp#initialized call s:on_initialized()
function! s:on_initialized()
" built-in setting
call lamp#builtin#intelephense()
call lamp#builtin#html_languageserver()
call lamp#builtin#css_languagserver()
call lamp#builtin#typescript_language_server()
call lamp#builtin#vim_language_server()
call lamp#builtin#gopls()
call lamp#builtin#rls()
call lamp#builtin#pyls()

" custom setting
call lamp#register('example-server', {
\ 'command': ['example-server', '--stdio'],
\ 'filetypes': ['example'],
\ 'root_uri': { -> lamp#findup(['.git', 'example.config.json']) },
\ 'initialization_options': { -> {
\ } },
\ 'capabilitis': {
\ 'completionProvider': {
\ 'triggerCharacters': [',']
\ }
\ }
\ })
endfunction

"
" initialize buffers
"
autocmd! vimrc User lamp#text_document_did_open call s:on_text_document_did_open()
function! s:on_text_document_did_open() abort
" completion
setlocal omnifunc=lamp#complete

" commands
nnoremap gf :LampDefinition edit
nnoremap gfs :LampDefinition split
nnoremap gfv :LampDefinition vsplit
nnoremap tgf :LampTypeDefinition edit
nnoremap tgfs :LampTypeDefinition split
nnoremap tgfv :LampTypeDefinition vsplit
nnoremap dgf :LampDeclaration edit
nnoremap dgfs :LampDeclaration split
nnoremap dgfv :LampDeclaration vsplit
nnoremap i :LampHover
nnoremap r :LampRename
nnoremap g :LampReferences
nnoremap @ :LampDocumentHighlight
nnoremap @ :LampDocumentHighlightClear
nnoremap f :LampFormatting
vnoremap f :LampRangeFormatting
nnoremap :LampCodeAction
vnoremap :LampCodeAction
nnoremap :LampSelectionRangeExpand
nnoremap :LampSelectionRangeCollapse
vnoremap :LampSelectionRangeExpand
vnoremap :LampSelectionRangeCollapse
nnoremap :LampDiagnosticsPrev
nnoremap :LampDiagnosticsNext
endfunction
```

# [Spec compatibility](https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/)

- General
- [x] initialize
- [x] initialized
- [x] shutdown
- [x] exit
- [x] $/cancelRequest
- [ ] $/progress

- Window
- [x] window/showMessage
- [x] window/showMessageRequest
- [x] window/logMessage
- [ ] window/workDoneProgress/create
- [ ] window/workDoneProgress/cancel

- Telemetry
- [x] telemetry/event

- Client
- [ ] ~~client/registerCapability~~ (Maybe unneeded)
- [ ] ~~client/unregisterCapability~~ (Maybe unneeded)

- Workspace
- [x] workspace/workspaceFolders
- [x] workspace/didChangeWorkspaceFolders
- [x] workspace/didChangeConfiguration
- [x] workspace/configuration
- [ ] workspace/didChangeWatchedFiles
- [ ] workspace/symbol
- [x] workspace/executeCommand
- [x] workspace/applyEdit

- Synchronization
- [x] textDocument/didOpen
- [x] textDocument/didChange
- [x] textDocument/willSave
- [x] textDocument/willSaveWaitUntil
- [x] textDocument/didSave
- [x] textDocument/didClose

- Diagnostics
- [x] textDocument/publishDiagnostics

- Language Features
- [x] textDocument/completion
- [x] completionItem/resolve
- [x] textDocument/hover
- [x] textDocument/signatureHelp
- [x] textDocument/declaration
- [x] textDocument/definition
- [x] textDocument/typeDefinition
- [x] textDocument/implementation
- [x] textDocument/references
- [x] textDocument/documentHighlight
- [ ] textDocument/documentSymbol
- [x] textDocument/codeAction
- [ ] textDocument/codeLens
- [ ] codeLens/resolve
- [ ] textDocument/documentLink
- [ ] documentLink/resolve
- [ ] textDocument/documentColor
- [ ] textDocument/colorPresentation
- [x] textDocument/formatting
- [x] textDocument/rangeFormatting
- [x] textDocument/onTypeFormatting
- [x] textDocument/rename
- [x] textDocument/prepareRename
- [ ] textDocument/foldingRange
- [x] textDocument/selectionRange

- Proposed
- [ ] textDocument/semanticTokens
- [ ] textDocument/callHierarchy

# TODO
- Use VS.System.Job and VS.RPC.JSON
- Support `textDocument/codeLens`
- Support `textDocument/onTypeFormatting` with ``
- Support `$/progress`
- Support `textDocument/semanticTokens`
- Support `textDocument/foldingRange`
- Custom highlighting in fenced language (e.g. underlined)
- Improve documentation