~tomleb/harepls

harepls/lsp.vim -rw-r--r-- 2.4 KiB
39d30373Tom Lebreux Invalidate identfinder result when local variable of same name 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
" install: curl https://raw.githubusercontent.com/prabirshrestha/vim-lsp/master/minimal.vimrc -o /tmp/minimal.vimrc
" uninstall: rm /tmp/plug.vim && rm -rf /tmp/plugged
" run vim/neovim with minimal.vimrc
" vim -u minimal.vimrc
" :PlugInstall

set nocompatible hidden laststatus=2

if !filereadable(expand('~/plug.vim'))
  silent !curl -fLo ~/plug.vim
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
endif

source ~/plug.vim

call plug#begin('~/.vim.plugged')
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
Plug 'https://git.sr.ht/~sircmpwn/hare.vim'
call plug#end()


let g:lsp_log_verbose=4
let g:lsp_log_file="/tmp/lsp-log"

imap <c-space> <Plug>(asyncomplete_force_refresh)
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>\<cr>" : "\<cr>"
autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif


let mapleader=","

function! s:lsp_enabled()
  " setl omnifunc=lsp#complete

  " if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif

  nmap <silent><buffer> K <Plug>(lsp-hover)
  " nmap <silent><buffer> <leader>r <Plug>(lsp-rename)
  " nmap <silent><buffer> <leader>c <Plug>(lsp-code-action)
  nmap <silent><buffer> <leader>gd <Plug>(lsp-definition)
  nmap <silent><buffer> <leader>gi <Plug>(lsp-implementation)
  nmap <silent><buffer> <leader>gs :call lsp#stop_server('harepls')<CR>
  " nmap <silent><buffer> <leader>[ <Plug>(lsp-previous-diagnostic)
  " nmap <silent><buffer> <leader>] <Plug>(lsp-next-diagnostic)
endfunction

augroup vim_lsp
  au!

  au User lsp_buffer_enabled :call <SID>lsp_enabled()
  au User lsp_setup call lsp#register_server({
      \ 'name': 'harepls',
      \ 'initialization_options': {
      \   'harepath': $HAREPATH,
      \ },
      \ 'allowlist': ['hare'],
      \ })
  " To display window/logMessage notifications
  au User lsp_setup call lsp#callbag#pipe(
    \ lsp#stream(),
    \ lsp#callbag#filter({x->has_key(x, 'response') && has_key(x['response'], 'method') && x['response']['method'] ==# 'window/logMessage'}),
    \ lsp#callbag#forEach({x->lsp#utils#echo_with_truncation(x['response']['params']['message'])})
    \ )
augroup END

augroup lsp_kludge
  au!
  au FileType markdown.lsp-hover setlocal filetype=markdown | setlocal conceallevel=2
augroup END

silent! colorscheme desu