
@Sisn/cds-lsp package that is delivered inside of the VS Code extension for CDS, available from the cloud section of the SAP Developer Tools site), which is the LanguageClient-neovim plugin for Vim.=> npm list -g --depth=0
/Users/i347491/.nvm/versions/node/v8.12.0/lib
├── @sap/cds@3.7.1
├── csvf@1.0.0 -> /Users/i347491/local/projects/csvf
├── npm@6.9.0
├── typescript@3.4.3
└── typescript-language-server@0.3.7ale_linters/ directory. For example, looking in the ale_linters/javascript/tsserver.vim file we see how it bootstraps and connects to the TypeScript LSP server for language services.@Sisn/cds-lsp implementation to get CDS language services in Vim, asynchronously? Turns out the answer is yes!vim-cds (and getting frustrated in my inconsistent use of 'folder' and 'directory' - see this Twitter poll for what others thing). In here we create an ftdetect directory that we can use to put some code to work out what file type we're dealing with when we load files with a cds extension:au BufNewFile,BufRead *.cds set filetype=cdsvim-cds/ directory to Vim configuration so it's used as a plugin, we can see that we now have Vim recognising CDS files. So far so good.syntax/, also containing a cds.vim file for syntax highlighting code, which is usually bookended like this:if (exists "b:current_syntax")
finish
endif
[...]
let b:current_syntax = "cds"syn off | syn on to restart syntax highlighting in Vim.vsix extension is just a compressed tarball in disguise) to find out how various sections of the CDS language had been defined. Specifically, there's a file syntaxes/cds.tmLanguage that identifies various keywords, how they appear, and what they are. This file extension and format (tmLanguage) comes from that (now-classic) editor TextMate and is used in VS Code.meta.controld.yield.cds, keyword.strong.control.cds and support.class.cds are examples of these.ale_linters/ directory in the ALE plugin to create a new directory cds/ to put what we need in there. Note that this is just temporary, we don't really want to be modifying another plugin, but for now, just to get things working, this will do.cds/ directory we need some Vimscript to bootstrap and connect to the CDS language server via the @Sisn/cds-lsp package, but we use a symbolic link to this Vimscript file which we create as cds.vim inside the vim-cds/ plugin directory..vim/ local/
| |
+- bundle/ +- projects/
| | symbolic |
| +- vim-cds/ -----------------------> +- vim-cds/
| | link |
| +- ale/ +- cds-lsp/ (extracted from the vsix file)
| | +----> +- cds.vim
| +- ale_linters/ | +- ftdetect/
| | | | |
| +- cds/ | | +- cds.vim
| | symbolic | |
| +- cds.vim ------------+ +- syntax/
| link | |
+- vimrc | +- cds.vim
|
+- startcdslspcds.vim, which starts up the language server in a way that ALE can connect to and make use of it:" Description: Simple config for using cds-lsp with ALE
call ale#Set('cds_cds_executable', $HOME . '/local/projects/vim-cds/startcdslsp')
function! ale_linters#cds#cds#GetProjectRoot(buffer) abort
let l:project_file = ale#path#FindNearestFile(a:buffer, '.cdsrc.json')
return fnamemodify(l:project_file, ':h')
endfunction
function! ale_linters#cds#cds#GetCommand(buffer) abort
let l:executable = ale#Var(a:buffer, 'cds_cds_executable')
return l:executable
endfunction
call ale#linter#Define('cds', {
\ 'name': 'cds',
\ 'lsp': 'stdio',
\ 'command': function('ale_linters#cds#cds#GetCommand'),
\ 'executable': {b -> ale#Var(b, 'cds_cds_executable')},
\ 'project_root': function('ale_linters#cds#cds#GetProjectRoot'),
\})startcdslsp which looks like this:#!/bin/bash
# Simple bootstrap script to start the CDS LSP server in STDIO mode.
# It assumes that the cds-lsp package directory is in the same directory
# as this script itself, for example:
#
# <dir>/
# |
# +-- cds-lsp/
# +-- startcdslsp
# Get the full name of the directory this script is in
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" > /dev/null 2>&1 && pwd)"
# Start the server
node "${DIR}/cds-lsp/out/src/server.js" --stdionpm install inside the cds-lsp/ directory that we took out of the vsix file, to bring in the packages that it needs, including the important one, @Sisn/cds-compiler!vimrc:set signcolumn=yes
let g:ale_completion_enabled = 1
let g:ale_sign_column_always = 1
let g:airline#extension#ale#enabled = 1
let g:ale_open_list = 1
nmap <silent><leader>j :lnext<cr>
nmap <silent><leader>k :lprevious<cr>You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 49 | |
| 49 | |
| 29 | |
| 23 | |
| 21 | |
| 15 | |
| 15 | |
| 14 | |
| 13 | |
| 13 |