From 7fa0f2261f862662352ae6da3cd038d57d0d1b80 Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Mon, 3 Apr 2023 00:12:31 +0200 Subject: [PATCH] Start example code at column 1 in README --- README.md | 142 +++++++++++++++++++++++++++--------------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 728d046..d5d428a 100644 --- a/README.md +++ b/README.md @@ -49,66 +49,66 @@ To use the plugin features with a particular file type(s), you need to first reg To register a LSP server, add the following lines to your .vimrc file (use only the LSP servers that you need from the below list). If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the LSP plugin, the steps are described later in this section. ```viml - function! TypeScriptCustomNotificationHandler(lspserver, reply) abort - echom printf("TypeScript Version = %s", a:reply.params.version) - endfunction - 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'], - \ customNotificationHandlers: { - \ '$/typescriptVersion': function('TypeScriptCustomNotificationHandler') - \ } - \ }, - \ #{ - \ filetype: 'sh', - \ path: '/usr/local/bin/bash-language-server', - \ args: ['start'] - \ }, - \ #{ - \ filetype: 'vim', - \ path: '/usr/local/bin/vim-language-server', - \ args: ['--stdio'] - \ }, - \ #{ - \ filetype: ['go', 'gomod'], - \ path: '/usr/local/bin/gopls', - \ args: ['serve'], - \ syncInit: v:true - \ }, - \ #{ - \ filetype: ['rust'], - \ path: '/usr/local/bin/rust-analyzer', - \ args: [], - \ syncInit: v:true - \ }, - \ #{ - \ filetype: ['python'], - \ path: '/usr/local/bin/pyls', - \ args: [] - \ }, - \ #{ - \ filetype: ['fortran'], - \ path: '/usr/local/bin/fortls', - \ args: ['--nthreads=1', '--use_signature_help', '--hover_signature'] - \ }, - \ #{ - \ filetype: ['php'], - \ path: '/usr/local/bin/intelephense', - \ args: ['--stdio'], - \ syncInit: v:true, - \ initializationOptions: #{ - \ licenceKey: 'absolute path to file with key or key itself' - \ } - \ } - \ ] - call LspAddServer(lspServers) +function! TypeScriptCustomNotificationHandler(lspserver, reply) abort + echom printf("TypeScript Version = %s", a:reply.params.version) +endfunction +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'], + \ customNotificationHandlers: { + \ '$/typescriptVersion': function('TypeScriptCustomNotificationHandler') + \ } + \ }, + \ #{ + \ filetype: 'sh', + \ path: '/usr/local/bin/bash-language-server', + \ args: ['start'] + \ }, + \ #{ + \ filetype: 'vim', + \ path: '/usr/local/bin/vim-language-server', + \ args: ['--stdio'] + \ }, + \ #{ + \ filetype: ['go', 'gomod'], + \ path: '/usr/local/bin/gopls', + \ args: ['serve'], + \ syncInit: v:true + \ }, + \ #{ + \ filetype: ['rust'], + \ path: '/usr/local/bin/rust-analyzer', + \ args: [], + \ syncInit: v:true + \ }, + \ #{ + \ filetype: ['python'], + \ path: '/usr/local/bin/pyls', + \ args: [] + \ }, + \ #{ + \ filetype: ['fortran'], + \ path: '/usr/local/bin/fortls', + \ args: ['--nthreads=1', '--use_signature_help', '--hover_signature'] + \ }, + \ #{ + \ filetype: ['php'], + \ path: '/usr/local/bin/intelephense', + \ args: ['--stdio'], + \ syncInit: v:true, + \ initializationOptions: #{ + \ licenceKey: 'absolute path to file with key or key itself' + \ } + \ } + \ ] +call LspAddServer(lspServers) ``` The above lines add the LSP servers for C, C++, Javascript, Typescript, Shell script, Vim script, Go, Rust, Python, Fortran and PHP file types. In addition to the above listed file types, this plugin also supports other file types. @@ -127,17 +127,17 @@ The LSP servers are added using the LspAddServer() function. This function accep If you used [vim-plug](https://github.com/junegunn/vim-plug) to install the LSP plugin, then you need to use the VimEnter autocmd to initialize the LSP server and to set the LSP server options. For example: ```viml - let lspServers = [ - \ #{ - \ filetype: ['c', 'cpp'], - \ path: '/usr/local/bin/clangd', - \ args: ['--background-index'] - \ } - \ ] - autocmd VimEnter * call LspAddServer(lspServers) - - let lspOpts = {'autoHighlightDiags': v:true} - autocmd VimEnter * call LspOptionsSet(lspOpts) +let lspServers = [ + \ #{ + \ filetype: ['c', 'cpp'], + \ path: '/usr/local/bin/clangd', + \ args: ['--background-index'] + \ } + \ ] +autocmd VimEnter * call LspAddServer(lspServers) + +let lspOpts = {'autoHighlightDiags': v:true} +autocmd VimEnter * call LspOptionsSet(lspOpts) ``` ## Supported Commands -- 2.48.1