Closed cpiber closed 2 years ago
Since I now sunk a few hours into this, maybe this is of help to some...
Assuming a version of ALE that allows lsp_config
(or initial_configuration
) for texlab
:
diff --git a/ale_linters/tex/texlab.vim b/ale_linters/tex/texlab.vim
index 0794bf5..cb660e1 100644
--- a/ale_linters/tex/texlab.vim
+++ b/ale_linters/tex/texlab.vim
@@ -4,6 +4,7 @@
call ale#Set('tex_texlab_executable', 'texlab')
call ale#Set('tex_texlab_options', '')
+call ale#Set('tex_texlab_config', {})
function! ale_linters#tex#texlab#GetProjectRoot(buffer) abort
let l:git_path = ale#path#FindNearestDirectory(a:buffer, '.git')
@@ -18,6 +19,7 @@ endfunction
call ale#linter#Define('tex', {
\ 'name': 'texlab',
\ 'lsp': 'stdio',
+\ 'lsp_config': {b -> ale#Var(b, 'tex_texlab_config')},
\ 'executable': {b -> ale#Var(b, 'tex_texlab_executable')},
\ 'command': function('ale_linters#tex#texlab#GetCommand'),
\ 'project_root': function('ale_linters#tex#texlab#GetProjectRoot'),
You can configure texlab
like this:
let g:ale_tex_texlab_config = {"build":{"onSave":v:true}}
Note the explicit dictionary and no (!) texlab
root.
I wouldn't recommend enabling forwardSearchAfter
, it didn't work properly in my experience[^1]. An alternative command you can call whenever you want to open the pdf and jump to the current position:
fun! ForwardSearch()
call ale#lsp_linter#SendRequest(bufnr('%'), 'texlab', [0, 'textDocument/forwardSearch', {'textDocument':{'uri':ale#path#ToURI(expand('#'.bufnr('%').':p'))},'position':{'line':line('.'),'character':col('.')}}])
endfun
command! -nargs=0 FwdSearch call ForwardSearch()
See the docs on how to configure the pdf viewer. I have not managed to make inverse search work.
[^1]: PDF viewer reloaded twice, and position was bogus; probably because full document is sent each time instead of just the diff. Also this takes focus from vim.
@cpiber based on your work I implemented a PR #4027 that allows to configure texlab LSP settings. Appreciated if you can check the PR and let me know if it works for you.
TexLab is configured solely by use of LSP configuration, set via
lsp_config
. ALE does not provide any way of setting that (and does not currently set it at all). Allowing to set that might also be useful for other linters.