~gpanders/dotfiles

ref: 8bbb6b42ada8c7e573ffba9c35b376dd6bec1d15 dotfiles/vim/.vim/after/plugin/ale.vim -rw-r--r-- 2.6 KiB
8bbb6b42Greg Anders Move weechat config directory to .config/weechat 2 years 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
" ALE configuration
" This file is executed AFTER ALE is loaded
" Author: Greg Anders <greg@gpanders.com>
" Date: 2019-01-23

let s:save_cpo = &cpo
set cpo&vim

if !get(g:, 'loaded_ale')
    finish
endif

if !exists('g:ale_linters')
    let g:ale_linters = {}
endif

" Python {{{
let g:ale_linters.python = ['pylint', 'flake8', 'pyls']
let g:ale_python_pylint_change_directory = 0
let g:ale_python_flake8_change_directory = 0
let g:ale_python_pyls_config = {
            \ 'pyls': {
            \   'configurationSources': ['flake8', 'pylint'],
            \   'plugins': {
            \     'pycodestyle': {
            \       'enabled': v:false,
            \     },
            \   },
            \ }}
" }}}

" C/C++ {{{
let g:ale_linters.c = ['clangd']
let g:ale_linters.cpp = g:ale_linters.c


let g:ale_c_clangd_options = '--clang-tidy --fallback-style=LLVM --background-index --suggest-missing-includes --header-insertion=iwyu'
let g:ale_cpp_clangd_options = g:ale_c_clangd_options . ' --clang-tidy-checks=cppcoreguidelines-*'

let g:ale_c_parse_makefile = 1
let g:ale_c_parse_compile_commands = 1

" }}}

" VHDL {{{
let g:ale_vhdl_xvhdl_options = '--2008 --nolog'
" }}}

" Rust {{{
let g:ale_linters.rust = ['cargo', 'rls']
let g:ale_rust_rls_toolchain = 'stable'

let g:ale_fixers = {
            \ 'python': ['isort'],
            \ 'cpp': ['clang-format'],
            \ 'c': ['clang-format'],
            \ '*': ['remove_trailing_lines', 'trim_whitespace']
            \}
" }}}

nmap <Space><C-F> <Plug>(ale_fix)
nmap <Bslash>gd <Plug>(ale_go_to_definition)
nmap <C-W><Bslash>d <Plug>(ale_go_to_definition_in_split)
nmap <Bslash>gr <Plug>(ale_find_references)

if get(g:, 'ale_completion_enabled')
    " See :h ale-completion-completeopt-bug
    set completeopt=menu,menuone,preview,noselect,noinsert
endif

function! s:lsp_setup()
    if empty(filter(ale#linter#Get(&filetype), {_, v -> !empty(v.lsp)}))
        return
    endif

    setlocal omnifunc=ale#completion#OmniFunc
    nnoremap <buffer> <C-]> :<C-U>ALEGoToDefinition<CR>
    nnoremap <buffer> <C-W>] :<C-U>ALEGoToDefinitionInSplit<CR>
    nnoremap <buffer> <C-W><C-]> :<C-U>ALEGoToDefinitionInSplit<CR>
    nnoremap <buffer> <Bslash>r :<C-U>ALEFindReferences<CR>
endfunction

function! s:toggle(...)
    if !&modifiable || &readonly
        silent ALEDisableBuffer
    elseif get(a:, '1', 1)
        silent ALEEnableBuffer
    endif
endfunction

augroup plugin.ale
    autocmd!
    autocmd OptionSet modifiable,readonly call <SID>toggle()
    autocmd BufWinEnter * call <SID>toggle(0)
    autocmd FileType * call <SID>lsp_setup()
augroup END

let &cpo = s:save_cpo
unlet s:save_cpo