Language Server Protocol (LSP) plugin for Vim9.
+# Installation
+
+You can install this plugin directly from github using the following steps:
+
+```
+ $ mkdir -p $HOME/.vim/pack/downloads/lsp
+ $ cd $HOME/.vim/packa/downloads/lsp
+ $ git clone https://github.com/yegappan/lsp
+```
+
+or you can use any one of the Vim plugin managers (dein.vim, pathogen, vam,
+vim-plug, volt, Vundle, etc.) to install and manage this plugin.
+
+You will also need to install one or more language servers corresponding to the
+programming languages that you are using. Refer to the https://langserver.org/
+page for the list of available language servers.
+
+# Configuration
+
+To register a LSP server, add the following lines to your .vimrc file:
+```
+ let lspServers = [
+ \ {
+ \ 'filetype': ['c', 'cpp'],
+ \ 'path': '/usr/local/bin/clangd',
+ \ 'args': ['--background-index']
+ \ },
+ \ {
+ \ 'filetype': ['javascript', 'typescript'],
+ \ 'path': '/usr/local/bin/typescript-language-server',
+ \ 'args': ['--stdio']
+ \ }
+ \ {
+ \ 'filetype': 'sh',
+ \ 'path': '/usr/local/bin/bash-language-server',
+ \ 'args': ['start']
+ \ },
+ \ ]
+ call lsp#addServer(lspServers)
+```
+
+The above lines add the LSP servers for C, C++, Javascript, Typescript and
+Shell script file types.
+
+To add a LSP server, the following information is needed:
+
+Field|Description
+-----|-----------
+filetype|One or more file types supported by the LSP server. This can be a String or a List. To specify multiple multiple file types, use a List.
+path|complete path to the LSP server executable (without any arguments).
+args|a list of command-line arguments passed to the LSP server. Each argument is a separate List item.
+
+The LSP servers are added using the lsp#addServer() function. This function
+accepts a list of LSP servers with the above information.
:setlocal modifiable
:silent! :%d _
- setline(1, ['# File Outline', '# ' .. fname])
+ setline(1, ['# LSP Outline View',
+ '# ' .. fnamemodify(fname, ':t') .. ' ('
+ .. fnamemodify(fname, ':h') .. ')'])
# First two lines in the buffer display comment information
var lnumMap: list<dict<any>> = [{}, {}]
def s:outlineCleanup()
# Remove the outline autocommands
:silent! autocmd! LSPOutline
+
+ :silent! syntax clear LSPTitle
enddef
# open the symbol outline window
:nnoremap <silent> <buffer> <CR> :call <SID>outlineJumpToSymbol()<CR>
:setlocal nomodifiable
+ # highlight all the symbol types
+ :syntax keyword LSPTitle File Module Namespace Package Class Method Property
+ :syntax keyword LSPTitle Field Constructor Enum Interface Function Variable
+ :syntax keyword LSPTitle Constant String Number Boolean Array Object Key Null
+ :syntax keyword LSPTitle EnumMember Struct Event Operator TypeParameter
+
+ if str2nr(&t_Co) > 2
+ highlight clear LSPTitle
+ highlight default link LSPTitle Title
+ endif
+
prop_type_add('LspOutlineHighlight', {bufnr: bufnr(), highlight: 'Search'})
augroup LSPOutline
cursor in a new quickfix list.
:LspHighlight Highlight all the matches for the keyword under cursor
:LspHighlightClear Clear all the matches highlighted by :LspHighlight
-:LspShowSymbols Show the list of symbols defined in the current file
+:LspOutline Show the list of symbols defined in the current file
in a separate window.
:LspFormat Format the current file using the LSP server.
:{range}LspFormat Format the specified range of files.
:LspRename Rename the current symbol
:LspCodeAction Apply the code action supplied by the LSP server to
the diagnostic in the current line.
+:LspSymbolSearch Perform a workspace wide search for a symbol
+:LSPSelectionRange Visually select the current symbol range
+:LSPFold Fold the current file
+:LspWorkspaceAddFolder {folder}
+ Add a folder to the workspace
+:LspWorkspaceRemoveFolder {folder}
+ Remove a folder from the workspace
+:LspWorkspaceListFolders
+ Show the list of folders in the workspace
==============================================================================
4. Configuration *lsp-configuration*
command! -nargs=0 -bar LspRename call lsp#rename()
command! -nargs=0 -bar LspCodeAction call lsp#codeAction()
command! -nargs=? -bar LspSymbolSearch call lsp#symbolSearch(<q-args>)
+command! -nargs=0 -bar LspSelectionRange call lsp#selectionRange()
+command! -nargs=0 -bar LspFold call lsp#foldDocument()
command! -nargs=0 -bar LspWorkspaceListFolders call lsp#listWorkspaceFolders()
command! -nargs=1 -bar -complete=dir LspWorkspaceAddFolder call lsp#addWorkspaceFolder(<q-args>)
command! -nargs=1 -bar -complete=dir LspWorkspaceRemoveFolder call lsp#removeWorkspaceFolder(<q-args>)
-command! -nargs=0 -bar LspSelectionRange call lsp#selectionRange()
-command! -nargs=0 -bar LspFold call lsp#foldDocument()