Adopt for vscode neovim plugin

This commit is contained in:
Oliver Hartmann 2021-06-12 20:07:54 +02:00
parent 2870ce61ee
commit 6db33686b5

389
init.vim
View File

@ -1,42 +1,43 @@
let HOSTNAME = substitute(system('hostname'), '\n', '', '') let HOSTNAME = substitute(system('hostname'), '\n', '', '')
" =============Plugins================== " =============Plugins==================
call plug#begin() if !exists('g:vscode')
Plug 'morhetz/gruvbox' call plug#begin()
Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' } Plug 'morhetz/gruvbox'
Plug 'chemzqm/denite-git' Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'tomtom/tcomment_vim' Plug 'chemzqm/denite-git'
Plug 'bling/vim-airline' Plug 'tomtom/tcomment_vim'
Plug 'vim-airline/vim-airline-themes' Plug 'bling/vim-airline'
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } Plug 'vim-airline/vim-airline-themes'
Plug 'tpope/vim-fugitive' " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'airblade/vim-gitgutter' Plug 'tpope/vim-fugitive'
Plug 'SirVer/ultisnips' Plug 'airblade/vim-gitgutter'
Plug 'honza/vim-snippets' Plug 'SirVer/ultisnips'
Plug 'vim-scripts/a.vim' Plug 'honza/vim-snippets'
Plug 'luochen1990/rainbow' Plug 'vim-scripts/a.vim'
if has("win32") Plug 'luochen1990/rainbow'
Plug 'autozimu/LanguageClient-neovim', { if has("win32")
\ 'branch': 'next', Plug 'autozimu/LanguageClient-neovim', {
\ 'do': 'powershell -executionpolicy bypass -File install.ps1', \ 'branch': 'next',
\ } \ 'do': 'powershell -executionpolicy bypass -File install.ps1',
else \ }
Plug 'autozimu/LanguageClient-neovim', { else
\ 'branch': 'next', Plug 'autozimu/LanguageClient-neovim', {
\ 'do': 'bash install.sh', \ 'branch': 'next',
\ } \ 'do': 'bash install.sh',
end \ }
Plug 'Shougo/echodoc.vim' end
Plug 'arakashic/chromatica.nvim', { 'do': ':UpdateRemotePlugins' } Plug 'Shougo/echodoc.vim'
Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} Plug 'arakashic/chromatica.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}}
Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'}
Plug 'neoclide/coc-lists', {'do': 'yarn install --frozen-lockfile'} Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'}
Plug 'kkoomen/vim-doge' Plug 'neoclide/coc-lists', {'do': 'yarn install --frozen-lockfile'}
call plug#end() Plug 'kkoomen/vim-doge'
call plug#end()
endif
" =============Paths===================== " =============Paths=====================
exec "source " . stdpath('config') . "/" . hostname() . ".vim" exec "source " . stdpath('config') . "/" . hostname() . ".vim"
" =============Settings================== " =============Settings==================
@ -89,51 +90,61 @@ vnoremap <leader>P "+P
autocmd BufEnter,FocusGained * checktime " Check for file modifications autocmd BufEnter,FocusGained * checktime " Check for file modifications
" =================Look and feel======================= " =================Look and feel=======================
set termguicolors if !exists('g:vscode')
set background=dark set termguicolors
colorscheme gruvbox set background=dark
colorscheme gruvbox
endif
" =================Filetypes=========================== " =================Filetypes===========================
au BufRead,BufNewFile *.simvis set filetype=xml if !exists('g:vscode')
au BufRead,BufNewFile *.simcfg set filetype=cfg au BufRead,BufNewFile *.simvis set filetype=xml
au BufRead,BufNewFile *.simcon set filetype=cfg au BufRead,BufNewFile *.simcfg set filetype=cfg
au BufRead,BufNewFile *.simudex set filetype=cfg au BufRead,BufNewFile *.simcon set filetype=cfg
au BufRead,BufNewFile Jenkinsfile* set filetype=groovy au BufRead,BufNewFile *.simudex set filetype=cfg
autocmd BufNewFile,BufRead *.manifest set filetype=xml au BufRead,BufNewFile Jenkinsfile* set filetype=groovy
autocmd BufNewFile,BufReadPre SConstruct set filetype=python autocmd BufNewFile,BufRead *.manifest set filetype=xml
autocmd BufNewFile,BufReadPre SConscript set filetype=python autocmd BufNewFile,BufReadPre SConstruct set filetype=python
autocmd FileType xml nnoremap <F10> :% !xmllint.exe "%" --format<CR> autocmd BufNewFile,BufReadPre SConscript set filetype=python
autocmd FileType json syntax match Comment +\/\/.\+$+ autocmd FileType xml nnoremap <F10> :% !xmllint.exe "%" --format<CR>
autocmd FileType json syntax match Comment +\/\/.\+$+
endif
" =================Windows and Tabs==================== " =================Windows and Tabs====================
" Open a new tab with F2 if !exists('g:vscode')
map <silent> <F2> <Esc>:tabnew <CR><ESC>:Explore<CR> " Open a new tab with F2
imap <silent> <F2> <Esc>:tabnew <CR><ESC>:Explore<CR> map <silent> <F2> <Esc>:tabnew <CR><ESC>:Explore<CR>
map <silent> <S-Right> :tabnext<CR> imap <silent> <F2> <Esc>:tabnew <CR><ESC>:Explore<CR>
map <silent> <S-Left> :tabprevious<CR> map <silent> <S-Right> :tabnext<CR>
nmap <silent> <A-Up> :wincmd k<CR> map <silent> <S-Left> :tabprevious<CR>
nmap <silent> <A-Down> :wincmd j<CR> nmap <silent> <A-Up> :wincmd k<CR>
nmap <silent> <A-Left> :wincmd h<CR> nmap <silent> <A-Down> :wincmd j<CR>
nmap <silent> <A-Right> :wincmd l<CR> nmap <silent> <A-Left> :wincmd h<CR>
" Open a new vertical split window with Ctrl - F2 nmap <silent> <A-Right> :wincmd l<CR>
map <silent> <C-F2> <Esc>:vsplit .<CR> " Open a new vertical split window with Ctrl - F2
imap <silent> <C-F2> <Esc>:vsplit .<CR> map <silent> <C-F2> <Esc>:vsplit .<CR>
" Open a new horizontal split window with Shift - F2 imap <silent> <C-F2> <Esc>:vsplit .<CR>
map <silent> <S-F2> <Esc>:split .<CR> " Open a new horizontal split window with Shift - F2
imap <silent> <S-F2> <Esc>:split .<CR> map <silent> <S-F2> <Esc>:split .<CR>
imap <silent> <S-F2> <Esc>:split .<CR>
endif
" ========================Codestyle======================== " ========================Codestyle========================
set tabstop=2 " Size of a tab if !exists('g:vscode')
set shiftwidth=2 " Die Einrückung set tabstop=2 " Size of a tab
set expandtab "Tabs get spaces when inserting set shiftwidth=2 " Die Einrückung
set softtabstop=0 set expandtab "Tabs get spaces when inserting
"set autoindent set softtabstop=0
"alignment ansi style (astyle) "set autoindent
set cindent " C-Code Style / Automatische Einrückung "alignment ansi style (astyle)
set cinoptions=(0,u0,U0,:0,=0 "Einrückung wie bei astyle: :0 (switch), =0 (case), (0 (unclosed parentheses), set cindent " C-Code Style / Automatische Einrückung
set modeline "Read indent comments (at end of file) set cinoptions=(0,u0,U0,:0,=0 "Einrückung wie bei astyle: :0 (switch), =0 (case), (0 (unclosed parentheses),
set modeline "Read indent comments (at end of file)
endif
" ======================shortcut======================= " ======================shortcut=======================
map <C-S> <ESC>:wa<CR> if !exists('g:vscode')
imap <C-S> <ESC>:wa<CR> map <C-S> <ESC>:wa<CR>
imap <C-S> <ESC>:wa<CR>
endif
"Jump to last modification line "Jump to last modification line
map ö `. map ö `.
nnoremap ü :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR> nnoremap ü :let @/='\<<C-R>=expand("<cword>")<CR>\>'<CR>:set hls<CR>
@ -150,119 +161,133 @@ vnoremap < <gv
vnoremap > >gv vnoremap > >gv
" ===========Linewrap and jumping============================= " ===========Linewrap and jumping=============================
setlocal wrap linebreak nolist if !exists('g:vscode')
set virtualedit= setlocal wrap linebreak nolist
setlocal display+=lastline set virtualedit=
nnoremap <silent> k gk setlocal display+=lastline
nnoremap <silent> j gj nnoremap <silent> k gk
nnoremap <silent> 0 g0 nnoremap <silent> j gj
nnoremap <silent> $ g$ nnoremap <silent> 0 g0
nnoremap <silent> <Up> gk nnoremap <silent> $ g$
nnoremap <silent> <Down> gj nnoremap <silent> <Up> gk
nnoremap <silent> <Home> g<Home> nnoremap <silent> <Down> gj
nnoremap <silent> <End> g<End> nnoremap <silent> <Home> g<Home>
vnoremap <silent> <Up> gk nnoremap <silent> <End> g<End>
vnoremap <silent> <Down> gj vnoremap <silent> <Up> gk
vnoremap <silent> <Home> g<Home> vnoremap <silent> <Down> gj
vnoremap <silent> <End> g<End> vnoremap <silent> <Home> g<Home>
vnoremap <silent> <End> g<End>
endif
" =================Comments============================ " =================Comments============================
map <C-C> :TComment<CR> if !exists('g:vscode')
map <C-C> :TComment<CR>
endif
" =========================Deoplete==================== " =========================Deoplete====================
let g:deoplete#enable_at_startup = 1 if !exists('g:vscode')
let g:deoplete#auto_complete_start_length = 1 let g:deoplete#enable_at_startup = 1
let g:deoplete#enable_smart_case = 1 let g:deoplete#auto_complete_start_length = 1
let g:deoplete#enable_smart_case = 1
endif
" =====================A====================== " =====================A======================
" Function for switching between header and c* files if !exists('g:vscode')
map <F5> :wa <CR> :A<CR> " Function for switching between header and c* files
imap <F5> <Esc>:wa<CR>:A<CR>i map <F5> :wa <CR> :A<CR>
map <C-F5> :AV<CR> imap <F5> <Esc>:wa<CR>:A<CR>i
imap <C-F5> <Esc>:AV<CR>i map <C-F5> :AV<CR>
map <S-F5> :AT<CR> imap <C-F5> <Esc>:AV<CR>i
imap <S-F5> <Esc>:AT<CR>i map <S-F5> :AT<CR>
let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,../../include,sfr:../inc,sfr:../h' imap <S-F5> <Esc>:AT<CR>i
" Dont create the file if the .cpp or .h is not found let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,../../include,sfr:../inc,sfr:../h'
let g:alternateNoDefaultAlternate = 1 " Dont create the file if the .cpp or .h is not found
let g:alternateNoDefaultAlternate = 1
" ===================UltiSnips================
let g:UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
let g:UltiSnipsJumpForwardTrigger = "<Tab>"
let g:UltiSnipsJumpBackwardTrigger = "<S-Tab>"
" ===========RAINBOW====================
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['lightblue', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'cpp': {
\ 'parentheses': [
\ 'start=/(/ end=/)/ fold',
\ 'start=/\[/ end=/\]/ fold',
\ 'start=/{/ end=/}/ fold',
\ 'start=/\(\(\<operator\>\)\@<!<\)\&[a-zA-Z0-9_]\@<=<\ze[^<]/ end=/>/']
\ },
\ 'cmake': {
\ 'parentheses': [],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
" ===================UltiSnips================
let g:UltiSnipsExpandTrigger = "<Plug>(ultisnips_expand)"
let g:UltiSnipsJumpForwardTrigger = "<Tab>"
let g:UltiSnipsJumpBackwardTrigger = "<S-Tab>"
" ===========RAINBOW====================
let g:rainbow_active = 1
let g:rainbow_conf = {
\ 'guifgs': ['lightblue', 'darkorange3', 'seagreen3', 'firebrick'],
\ 'ctermfgs': ['lightblue', 'lightyellow', 'lightcyan', 'lightmagenta'],
\ 'operators': '_,_',
\ 'parentheses': ['start=/(/ end=/)/ fold', 'start=/\[/ end=/\]/ fold', 'start=/{/ end=/}/ fold'],
\ 'separately': {
\ '*': {},
\ 'tex': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/'],
\ },
\ 'cpp': {
\ 'parentheses': [
\ 'start=/(/ end=/)/ fold',
\ 'start=/\[/ end=/\]/ fold',
\ 'start=/{/ end=/}/ fold',
\ 'start=/\(\(\<operator\>\)\@<!<\)\&[a-zA-Z0-9_]\@<=<\ze[^<]/ end=/>/']
\ },
\ 'cmake': {
\ 'parentheses': [],
\ },
\ 'lisp': {
\ 'guifgs': ['royalblue3', 'darkorange3', 'seagreen3', 'firebrick', 'darkorchid3'],
\ },
\ 'vim': {
\ 'parentheses': ['start=/(/ end=/)/', 'start=/\[/ end=/\]/', 'start=/{/ end=/}/ fold', 'start=/(/ end=/)/ containedin=vimFuncBody', 'start=/\[/ end=/\]/ containedin=vimFuncBody', 'start=/{/ end=/}/ fold containedin=vimFuncBody'],
\ },
\ 'html': {
\ 'parentheses': ['start=/\v\<((area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)[ >])@!\z([-_:a-zA-Z0-9]+)(\s+[-_:a-zA-Z0-9]+(\=("[^"]*"|'."'".'[^'."'".']*'."'".'|[^ '."'".'"><=`]*))?)*\>/ end=#</\z1># fold'],
\ },
\ 'css': 0,
\ }
\}
endif
" ===================LanguageServer================== " ===================LanguageServer==================
if has("win32") if !exists('g:vscode')
let g:LanguageClient_serverCommands = { if has("win32")
\ 'cpp': ['clangd'], let g:LanguageClient_serverCommands = {
\ } \ 'cpp': ['clangd'],
else \ }
let g:LanguageClient_serverCommands = { else
\ 'cpp': ['cquery', let g:LanguageClient_serverCommands = {
\ '--log-file=/tmp/cq.log', \ 'cpp': ['cquery',
\ '--init={"cacheDirectory":"/tmp/cquery/"}'] \ '--log-file=/tmp/cq.log',
\ } \ '--init={"cacheDirectory":"/tmp/cquery/"}']
end \ }
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR> end
nnoremap <silent> gd :call LanguageClient#textDocument_definition({'gotoCmd': 'tabedit'})<CR> nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
nnoremap <silent> <F3> :call LanguageClient_contextMenu()<CR> nnoremap <silent> gd :call LanguageClient#textDocument_definition({'gotoCmd': 'tabedit'})<CR>
vnoremap <silent> <F3> :call LanguageClient_contextMenu()<CR> nnoremap <silent> <F3> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> <F6> :call LanguageClient_textDocument_documentSymbol()<CR> vnoremap <silent> <F3> :call LanguageClient_contextMenu()<CR>
nnoremap <silent> <F6> :call LanguageClient_textDocument_documentSymbol()<CR>
let g:LanguageClient_hasClientSupport = 0 let g:LanguageClient_hasClientSupport = 0
" ===================EchoDoc========================= " ===================EchoDoc=========================
set cmdheight=2 set cmdheight=2
let g:echodoc#enable_at_startup = 1 let g:echodoc#enable_at_startup = 1
let g:echodoc#type = 'signature' let g:echodoc#type = 'signature'
endif
" ===================FZF============================= " ===================FZF=============================
nnoremap <C-P> :FZF<CR> if !exists('g:vscode')
let g:fzf_action = { nnoremap <C-P> :FZF<CR>
\ 'enter': 'tab split', let g:fzf_action = {
\ 'ctrl-x': 'split', \ 'enter': 'tab split',
\ 'ctrl-v': 'vsplit' } \ 'ctrl-x': 'split',
\ 'ctrl-v': 'vsplit' }
endif
" ===================Chromatica====================== " ===================Chromatica======================
let g:chromatica#enable_at_startup=1 if !exists('g:vscode')
let g:chromatica#enable_at_startup=1
endif
" ===================COC============================= " ===================COC=============================
inoremap <silent><expr> <c-space> coc#refresh() if !exists('g:vscode')
autocmd CursorHold * silent call CocActionAsync('highlight') inoremap <silent><expr> <c-space> coc#refresh()
set updatetime=500 " After ms should CursorHold trigger autocmd CursorHold * silent call CocActionAsync('highlight')
" Remap for format selected region set updatetime=500 " After ms should CursorHold trigger
vmap <leader>f <Plug>(coc-format-selected) " Remap for format selected region
nmap <leader>f <Plug>(coc-format-selected) vmap <leader>f <Plug>(coc-format-selected)
nmap <leader>f <Plug>(coc-format-selected)
nmap <leader>r <Plug>(coc-rename) nmap <leader>r <Plug>(coc-rename)
" Use `:Format` for format current buffer " Use `:Format` for format current buffer
@ -298,8 +323,10 @@ endfunction
nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr> nnoremap <silent> <space>y :<C-u>CocList -A --normal yank<cr>
" ===================Denite========================== " ===================Denite==========================
call denite#custom#map('insert', '<Down>', '<denite:move_to_next_line>', 'noremap') if !exists('g:vscode')
call denite#custom#map('insert', '<Up>', '<denite:move_to_previous_line>', 'noremap') call denite#custom#map('insert', '<Down>', '<denite:move_to_next_line>', 'noremap')
call denite#custom#map('insert', '<Up>', '<denite:move_to_previous_line>', 'noremap')
nnoremap <C-P> :Denite -default-action=tabopen file/rec<CR> nnoremap <C-P> :Denite -default-action=tabopen file/rec<CR>
nnoremap <C-B> :Denite buffer<CR> nnoremap <C-B> :Denite buffer<CR>
endif