-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add multiple language server association with syntax elements
- Loading branch information
Indelog
committed
Apr 10, 2024
1 parent
8255965
commit 1b8a084
Showing
9 changed files
with
179 additions
and
9 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
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
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,68 @@ | ||
vim9script | ||
|
||
import '../autoload/lsp/buffer.vim' as buf | ||
import '../autoload/lsp/util.vim' as util | ||
|
||
source common.vim | ||
|
||
g:markdown_fenced_languages = ['c'] | ||
|
||
var lspServers = [ | ||
{ | ||
name: 'marksman', | ||
filetype: 'markdown', | ||
path: (exepath('marksman') ?? expand('~') .. '/.local/bin/marksman'), | ||
args: ['server'], | ||
}, | ||
{ | ||
name: 'clangd', | ||
filetype: 'markdown', | ||
path: (exepath('clangd-15') ?? exepath('clangd')), | ||
args: ['--background-index', '--clang-tidy'], | ||
syntaxAssociatedLSP: ['markdownHighlight_c', 'markdownHighlightc'], | ||
|
||
}, | ||
] | ||
call LspAddServer(lspServers) | ||
|
||
def FillDummyFile() | ||
:silent edit dummy.md | ||
sleep 200m | ||
var lines: list<string> =<< trim END | ||
# Title | ||
|
||
```c | ||
int f1() { | ||
int x; | ||
int y; | ||
x = 1; | ||
y = 2; | ||
return x + y; | ||
} | ||
``` | ||
END | ||
setline(1, lines) | ||
enddef | ||
|
||
def g:Test_ChoseDefaultLspIfNoSyntaxMatch() | ||
FillDummyFile() | ||
search('Title') | ||
var selected_lsp = buf.BufLspServerGet(bufnr(), 'hover') | ||
assert_true(selected_lsp->has_key('name')) | ||
assert_equal(selected_lsp.name, 'marksman') | ||
enddef | ||
|
||
def g:Test_ChooseCorrectLspIfSyntaxMatch() | ||
FillDummyFile() | ||
search('int') | ||
var selected_lsp = buf.BufLspServerGet(bufnr(), 'hover') | ||
assert_true(selected_lsp->has_key('name')) | ||
assert_equal(selected_lsp.name, 'clangd') | ||
enddef | ||
|
||
# Only here to because the test runner needs it | ||
def g:StartLangServer(): bool | ||
return true | ||
enddef | ||
|
||
# vim: shiftwidth=2 softtabstop=2 noexpandtab |