-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for c3-lsp linter (#4836)
* Add support for c3-lsp linter Add support for c3-lang with the c3-lsp language server. Link: http://github.com/pherrymason/c3-lsp Link: http://c3-lang.org * fix linter error * fix: consistent use of the executable name Consistently use the executable name 'c3lsp' instead of the project name 'c3-lsp'. * c3lsp: add command line arguments to executable
- Loading branch information
Showing
7 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
" Author: Koni Marti <[email protected]> | ||
" Description: A Language Server implementation for C3 | ||
|
||
call ale#Set('c3_c3lsp_executable', 'c3lsp') | ||
call ale#Set('c3_c3lsp_options', '') | ||
call ale#Set('c3_c3lsp_init_options', {}) | ||
|
||
function! ale_linters#c3#c3lsp#GetCommand(buffer) abort | ||
let l:executable = ale#Var(a:buffer, 'c3_c3lsp_executable') | ||
|
||
return ale#Escape(l:executable) . ale#Pad(ale#Var(a:buffer, 'c3_c3lsp_options')) | ||
endfunction | ||
|
||
|
||
call ale#linter#Define('c3', { | ||
\ 'name': 'c3lsp', | ||
\ 'lsp': 'stdio', | ||
\ 'executable': {b -> ale#Var(b, 'c3_c3lsp_executable')}, | ||
\ 'command': function('ale_linters#c3#c3lsp#GetCommand'), | ||
\ 'project_root': function('ale#handlers#c3lsp#GetProjectRoot'), | ||
\ 'lsp_config': {b -> ale#handlers#c3lsp#GetInitOpts(b, 'c3_c3lsp_init_options')}, | ||
\}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
scriptencoding utf-8 | ||
" Author: Koni Marti <[email protected]> | ||
" Description: Utilities for c3lsp | ||
|
||
function! ale#handlers#c3lsp#GetProjectRoot(buffer) abort | ||
let l:config = ale#path#FindNearestFile(a:buffer, 'project.json') | ||
|
||
if !empty(l:config) | ||
return fnamemodify(l:config, ':h') | ||
endif | ||
|
||
return expand('#' . a:buffer . ':p:h') | ||
endfunction | ||
|
||
function! ale#handlers#c3lsp#GetInitOpts(buffer, init_options_var) abort | ||
let l:init_options = {} | ||
|
||
return extend(l:init_options, ale#Var(a:buffer, a:init_options_var)) | ||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
=============================================================================== | ||
ALE C3 Integration *ale-c3-options* | ||
|
||
=============================================================================== | ||
c3lsp *ale-c3-c3lsp* | ||
|
||
g:ale_c3_c3lsp_executable *g:ale_c3_c3lsp_executable* | ||
*b:ale_c3_c3lsp_executable* | ||
Type: |String| | ||
Default: `c3lsp` | ||
|
||
This variable can be changed to set the path to c3lsp executable. | ||
|
||
|
||
g:ale_c3_c3lsp_options *g:ale_c3_c3lsp_options* | ||
*b:ale_c3_c3lsp_options* | ||
|
||
Type: |String| | ||
Default: `''` | ||
|
||
Add command line options to the c3lsp executable. This is useful to specify | ||
the path to the C3 standard library with '-stdlib-path=<path>'. | ||
|
||
|
||
g:ale_c3_c3lsp_init_options *g:ale_c3_c3lsp_init_options* | ||
*b:ale_c3_c3lsp_init_options* | ||
Type: |Dictionary| | ||
Default: `{}` | ||
|
||
Dictionary containing configuration settings that will be passed to the | ||
language server. | ||
|
||
|
||
=============================================================================== | ||
vim:tw=78:ts=2:sts=2:sw=2:ft=help:norl: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Before: | ||
call ale#assert#SetUpLinterTest('c3', 'c3lsp') | ||
|
||
After: | ||
call ale#assert#TearDownLinterTest() | ||
|
||
Execute(The default c3lsp settings should be correct): | ||
AssertLinter 'c3lsp', ale#Escape('c3lsp') | ||
AssertLSPConfig {} | ||
|
||
Execute(c3lsp should be configurable): | ||
let b:ale_c3_c3lsp_executable = 'billy' | ||
let b:ale_c3_c3lsp_init_options = {'x': 'y'} | ||
|
||
AssertLinter 'billy', ale#Escape('billy') | ||
AssertLSPConfig {'x': 'y'} |