Skip to content

Instantly share code, notes, and snippets.

@kLabz kLabz/haxelsp.md
Last active Apr 18, 2019

Embed
What would you like to do?
Haxe + LSP + Neovim
function! k#haxelsp#DisplayServerConfig(serverConfig)
call LanguageClient#Notify('haxe/didChangeDisplayServerConfig', a:serverConfig)
endfunction
function! k#haxelsp#SelectHxml(hxml)
if filereadable(a:hxml)
call LanguageClient#Notify('haxe/didChangeDisplayArguments', {'arguments': [a:hxml]})
endif
endfunction
function! k#haxelsp#HxmlSelector()
call fzf#vim#files('', {'source': 'ag -g ".hxml"', 'down': '40%', 'sink': function('k#haxelsp#SelectHxml')})
endfunction
function! k#haxelsp#SetConfig()
if &ft=="haxe"
" Use local server-config if any
if filereadable('.vim/haxe-lsp-displayserver.json')
let serverConfig = json_decode(system("cat .vim/haxe-lsp-displayserver.json"))
call k#haxelsp#DisplayServerConfig(serverConfig)
endif
" Use local hxml config instead of build.hxml if any
if filereadable('.vim/default-hxml')
call k#haxelsp#SelectHxml(json_decode(system('cat .vim/default-hxml')))
else
call k#haxelsp#SelectHxml('build.hxml')
endif
" Use local haxe settings if any
if filereadable('.vim/haxe-lsp-settings.json')
let haxeConfig = json_decode(system('cat .vim/haxe-lsp-settings.json'))
else
let haxeConfig = json_decode(system('cat ~/.config/nvim/haxelsp/settings-haxe.json'))
endif
call LanguageClient#Notify('workspace/didChangeConfiguration', {'settings': {'haxe': haxeConfig}})
endif
endfunction
call plug#begin()
" ...
Plug 'autozimu/LanguageClient-neovim', {'branch': 'next', 'do': 'bash install.sh'}
Plug 'roxma/nvim-completion-manager'
Plug 'jdonaldson/vaxe'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
" ...
call plug#end()
" ...
" Language server protocol
let g:LanguageClient_serverCommands = {
\ 'haxe': ['node', '/git/haxe-languageserver/bin/server.js'],
\ }
let g:LanguageClient_autoStart = 1
let g:LanguageClient_settingsPath = '~/.config/nvim/haxelsp/settings.json'
let g:LanguageClient_loadSettings = 1
" let g:LanguageClient_loggingLevel = 'DEBUG'
" Auto config Haxe LSP
augroup LanguageClient_config
autocmd!
autocmd User LanguageClientStarted call k#haxelsp#SetConfig()
augroup END
{
"enableDiagnostics": true,
"diagnosticsPathFilter": "",
"enableCodeLens": true,
"displayPort": "auto",
"buildCompletionCache": true,
"codeGeneration": {},
"format": {}
}
{
"initializationOptions": {
"displayServerConfig": {
"env": {},
"path": "/usr/bin/haxe",
"arguments": []
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.