aboutsummaryrefslogtreecommitdiff
path: root/.vim/plugin/init.vim
blob: b7a06c4d6603d55240de4cbc8b043b364903eaa5 (plain)
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
if empty(glob('~/.vim/autoload/plug.vim'))
  silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
    \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

let s:settings = split(expand('~/.vim/plugin/*.vim'))

function! s:load_settings()
    for setting in s:settings
        if setting !~ 'init.vim'
            exec "source " . setting
        endif
    endfor
endfunction

function! BuildYCM(info)
    let ycm_install_options=' --clangd-completer'

    if !empty(glob("/usr/bin/go")) || !empty(glob("/usr/local/bin/go"))
       let ycm_install_options = ycm_install_options . ' --go-completer'
    endif

    exec '!python3 ./install.py' . ycm_install_options
endfunction

let g:ycm_language_server = []

call plug#begin('~/.vim/plugged')

" General
Plug 'Valloric/YouCompleteMe', {
            \ 'do': function('BuildYCM'),
            \ }
Plug 'prabirshrestha/vim-lsp'

Plug 'dense-analysis/ale'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-sleuth' " Automatically adjust indent
Plug 'godlygeek/tabular'
Plug 'airblade/vim-rooter'
Plug 'ludovicchabant/vim-gutentags'

Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'

let g:airline#extensions#tabline#enabled = 1
Plug 'tpope/vim-fugitive'

nnoremap <silent> <leader>gl :Gclog! -- %<CR>
nnoremap <silent> <leader>gd :Gdiffsplit <CR>
nnoremap <silent> <leader>gs :G<CR>

Plug 'easymotion/vim-easymotion'

map <Space> <Plug>(easymotion-prefix)

Plug 'editorconfig/editorconfig-vim'

" Language specific
Plug 'habamax/vim-godot', {'for': 'gdscript'}
Plug 'scrooloose/nerdtree', {'on': 'NERDTreeToggle'}
Plug 'ledger/vim-ledger', {'for': 'ledger'}

Plug 'iamcco/markdown-preview.nvim', {
            \ 'do': {-> mkdp#util#install()},
            \ 'for': ['markdown', 'vim-plug']
            \ }

Plug 'mhinz/vim-signify'
Plug 'tpope/vim-unimpaired'
Plug 'voldikss/vim-floaterm' " Use :FloatermNew to open floating terminal

Plug 'joshdick/onedark.vim'
Plug 'liuchengxu/vista.vim'

let g:vista_default_executive = 'ctags'

let g:vista_executive_for = {
            \ 'go': 'vim_lsp',
            \ }

Plug 'puremourning/vimspector', { 'on': '<Plug>VimspectorContinue' }

let g:vimspector_install_gadgets = ['debugpy']

nmap <silent> <Leader>dc <Plug>VimspectorContinue
nmap <silent> <Leader>dq <Plug>VimspectorStop
nmap <silent> <Leader>db <Plug>VimspectorToggleBreakpoint
nmap <silent> <Leader>dn <Plug>VimspectorStepOver
nmap <silent> <Leader>ds <Plug>VimspectorStepInto
nmap <silent> <Leader>df <Plug>VimspectorStepOut
nmap <silent> <Leader>di <Plug>VimspectorBalloonEval
xmap <silent> <Leader>di <Plug>VimspectorBalloonEval

let s:mapped = {}

function! s:set_debug_keymaps() abort
    if has_key(s:mapped, string(bufnr()))
        return
    endif

    " nmap <silent> <buffer> c <Plug>VimspectorContinue
    " nmap <silent> <buffer> q <Plug>VimspectorStop
    " nmap <silent> <buffer> b <Plug>VimspectorToggleBreakpoint
    nmap <silent> <buffer> m <Plug>VimspectorStepOver
    " nmap <silent> <buffer> s <Plug>VimspectorStepInto
    " nmap <silent> <buffer> f <Plug>VimspectorStepOut
    " nmap <silent> <buffer> i <Plug>VimspectorBalloonEval
    " xmap <silent> <buffer> i <Plug>VimspectorBalloonEval

    let s:mapped[string(bufnr())] = {'modifiable': &modifiable}

    setlocal nomodifiable
endfunction

function! s:unset_debug_keymaps() abort
    let original_buf = bufnr()
    let hidden = &hidden

    try
        set hidden
        for bufnr in keys(s:mapped)
            try
                execute 'noautocmd buffer' bufnr
                " silent! nunmap <buffer> c
                " silent! nunmap <buffer> q
                " silent! nunmap <buffer> b
                silent! nunmap <buffer> m
                " silent! nunmap <buffer> s
                " silent! nunmap <buffer> f
                " silent! nunmap <buffer> i
                " silent! xunmap <buffer> i
                
                let &l:modifiable = s:mapped[bufnr]['modifiable']
            endtry
        endfor
    finally
        execute 'noautocmd buffer' original_buf
        let &hidden = hidden
    endtry

    let s:mapped = {}
endfunction

augroup CustomMappings
    au!
    autocmd User VimspectorJumpedToFrame call s:set_debug_keymaps()
    autocmd User VimspectorDebugEnded call s:unset_debug_keymaps()
augroup end
call plug#end()

call s:load_settings()