From 6db33686b5b195251e9fe4c125fec3730e5f6685 Mon Sep 17 00:00:00 2001 From: Oliver Hartmann Date: Sat, 12 Jun 2021 20:07:54 +0200 Subject: [PATCH] Adopt for vscode neovim plugin --- init.vim | 389 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 208 insertions(+), 181 deletions(-) diff --git a/init.vim b/init.vim index 1adef2b..58e9866 100644 --- a/init.vim +++ b/init.vim @@ -1,42 +1,43 @@ let HOSTNAME = substitute(system('hostname'), '\n', '', '') " =============Plugins================== -call plug#begin() -Plug 'morhetz/gruvbox' -Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'chemzqm/denite-git' -Plug 'tomtom/tcomment_vim' -Plug 'bling/vim-airline' -Plug 'vim-airline/vim-airline-themes' -" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'tpope/vim-fugitive' -Plug 'airblade/vim-gitgutter' -Plug 'SirVer/ultisnips' -Plug 'honza/vim-snippets' -Plug 'vim-scripts/a.vim' -Plug 'luochen1990/rainbow' -if has("win32") - Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'powershell -executionpolicy bypass -File install.ps1', - \ } -else - Plug 'autozimu/LanguageClient-neovim', { - \ 'branch': 'next', - \ 'do': 'bash install.sh', - \ } -end -Plug 'Shougo/echodoc.vim' -Plug 'arakashic/chromatica.nvim', { 'do': ':UpdateRemotePlugins' } -Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} -Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'} -Plug 'neoclide/coc-lists', {'do': 'yarn install --frozen-lockfile'} -Plug 'kkoomen/vim-doge' -call plug#end() - +if !exists('g:vscode') + call plug#begin() + Plug 'morhetz/gruvbox' + Plug 'Shougo/denite.nvim', { 'do': ':UpdateRemotePlugins' } + Plug 'chemzqm/denite-git' + Plug 'tomtom/tcomment_vim' + Plug 'bling/vim-airline' + Plug 'vim-airline/vim-airline-themes' + " Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } + Plug 'tpope/vim-fugitive' + Plug 'airblade/vim-gitgutter' + Plug 'SirVer/ultisnips' + Plug 'honza/vim-snippets' + Plug 'vim-scripts/a.vim' + Plug 'luochen1990/rainbow' + if has("win32") + Plug 'autozimu/LanguageClient-neovim', { + \ 'branch': 'next', + \ 'do': 'powershell -executionpolicy bypass -File install.ps1', + \ } + else + Plug 'autozimu/LanguageClient-neovim', { + \ 'branch': 'next', + \ 'do': 'bash install.sh', + \ } + end + Plug 'Shougo/echodoc.vim' + Plug 'arakashic/chromatica.nvim', { 'do': ':UpdateRemotePlugins' } + Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} + Plug 'neoclide/coc-json', {'do': 'yarn install --frozen-lockfile'} + Plug 'neoclide/coc-python', {'do': 'yarn install --frozen-lockfile'} + Plug 'neoclide/coc-yaml', {'do': 'yarn install --frozen-lockfile'} + Plug 'neoclide/coc-highlight', {'do': 'yarn install --frozen-lockfile'} + Plug 'neoclide/coc-snippets', {'do': 'yarn install --frozen-lockfile'} + Plug 'neoclide/coc-lists', {'do': 'yarn install --frozen-lockfile'} + Plug 'kkoomen/vim-doge' + call plug#end() +endif " =============Paths===================== exec "source " . stdpath('config') . "/" . hostname() . ".vim" " =============Settings================== @@ -89,51 +90,61 @@ vnoremap P "+P autocmd BufEnter,FocusGained * checktime " Check for file modifications " =================Look and feel======================= -set termguicolors -set background=dark -colorscheme gruvbox +if !exists('g:vscode') + set termguicolors + set background=dark + colorscheme gruvbox +endif " =================Filetypes=========================== -au BufRead,BufNewFile *.simvis set filetype=xml -au BufRead,BufNewFile *.simcfg set filetype=cfg -au BufRead,BufNewFile *.simcon set filetype=cfg -au BufRead,BufNewFile *.simudex set filetype=cfg -au BufRead,BufNewFile Jenkinsfile* set filetype=groovy -autocmd BufNewFile,BufRead *.manifest set filetype=xml -autocmd BufNewFile,BufReadPre SConstruct set filetype=python -autocmd BufNewFile,BufReadPre SConscript set filetype=python -autocmd FileType xml nnoremap :% !xmllint.exe "%" --format -autocmd FileType json syntax match Comment +\/\/.\+$+ +if !exists('g:vscode') + au BufRead,BufNewFile *.simvis set filetype=xml + au BufRead,BufNewFile *.simcfg set filetype=cfg + au BufRead,BufNewFile *.simcon set filetype=cfg + au BufRead,BufNewFile *.simudex set filetype=cfg + au BufRead,BufNewFile Jenkinsfile* set filetype=groovy + autocmd BufNewFile,BufRead *.manifest set filetype=xml + autocmd BufNewFile,BufReadPre SConstruct set filetype=python + autocmd BufNewFile,BufReadPre SConscript set filetype=python + autocmd FileType xml nnoremap :% !xmllint.exe "%" --format + autocmd FileType json syntax match Comment +\/\/.\+$+ +endif " =================Windows and Tabs==================== -" Open a new tab with F2 -map :tabnew :Explore -imap :tabnew :Explore -map :tabnext -map :tabprevious -nmap :wincmd k -nmap :wincmd j -nmap :wincmd h -nmap :wincmd l -" Open a new vertical split window with Ctrl - F2 -map :vsplit . -imap :vsplit . -" Open a new horizontal split window with Shift - F2 -map :split . -imap :split . +if !exists('g:vscode') + " Open a new tab with F2 + map :tabnew :Explore + imap :tabnew :Explore + map :tabnext + map :tabprevious + nmap :wincmd k + nmap :wincmd j + nmap :wincmd h + nmap :wincmd l + " Open a new vertical split window with Ctrl - F2 + map :vsplit . + imap :vsplit . + " Open a new horizontal split window with Shift - F2 + map :split . + imap :split . +endif " ========================Codestyle======================== -set tabstop=2 " Size of a tab -set shiftwidth=2 " Die Einrückung -set expandtab "Tabs get spaces when inserting -set softtabstop=0 -"set autoindent -"alignment ansi style (astyle) -set cindent " C-Code Style / Automatische Einrückung -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) +if !exists('g:vscode') + set tabstop=2 " Size of a tab + set shiftwidth=2 " Die Einrückung + set expandtab "Tabs get spaces when inserting + set softtabstop=0 + "set autoindent + "alignment ansi style (astyle) + set cindent " C-Code Style / Automatische Einrückung + 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======================= -map :wa -imap :wa +if !exists('g:vscode') + map :wa + imap :wa +endif "Jump to last modification line map ö `. nnoremap ü :let @/='\<=expand("")\>':set hls @@ -150,119 +161,133 @@ vnoremap < >gv " ===========Linewrap and jumping============================= -setlocal wrap linebreak nolist -set virtualedit= -setlocal display+=lastline -nnoremap k gk -nnoremap j gj -nnoremap 0 g0 -nnoremap $ g$ -nnoremap gk -nnoremap gj -nnoremap g -nnoremap g -vnoremap gk -vnoremap gj -vnoremap g -vnoremap g +if !exists('g:vscode') + setlocal wrap linebreak nolist + set virtualedit= + setlocal display+=lastline + nnoremap k gk + nnoremap j gj + nnoremap 0 g0 + nnoremap $ g$ + nnoremap gk + nnoremap gj + nnoremap g + nnoremap g + vnoremap gk + vnoremap gj + vnoremap g + vnoremap g +endif " =================Comments============================ -map :TComment +if !exists('g:vscode') + map :TComment +endif " =========================Deoplete==================== -let g:deoplete#enable_at_startup = 1 -let g:deoplete#auto_complete_start_length = 1 -let g:deoplete#enable_smart_case = 1 +if !exists('g:vscode') + let g:deoplete#enable_at_startup = 1 + let g:deoplete#auto_complete_start_length = 1 + let g:deoplete#enable_smart_case = 1 +endif " =====================A====================== -" Function for switching between header and c* files -map :wa :A -imap :wa:Ai -map :AV -imap :AVi -map :AT -imap :ATi -let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,../../include,sfr:../inc,sfr:../h' -" Dont create the file if the .cpp or .h is not found -let g:alternateNoDefaultAlternate = 1 - -" ===================UltiSnips================ -let g:UltiSnipsExpandTrigger = "(ultisnips_expand)" -let g:UltiSnipsJumpForwardTrigger = "" -let g:UltiSnipsJumpBackwardTrigger = "" -" ===========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=/\(\(\\)\@/'] - \ }, - \ '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=## fold'], - \ }, - \ 'css': 0, - \ } - \} +if !exists('g:vscode') + " Function for switching between header and c* files + map :wa :A + imap :wa:Ai + map :AV + imap :AVi + map :AT + imap :ATi + let g:alternateSearchPath = 'sfr:../source,sfr:../src,sfr:../include,../../include,sfr:../inc,sfr:../h' + " Dont create the file if the .cpp or .h is not found + let g:alternateNoDefaultAlternate = 1 + " ===================UltiSnips================ + let g:UltiSnipsExpandTrigger = "(ultisnips_expand)" + let g:UltiSnipsJumpForwardTrigger = "" + let g:UltiSnipsJumpBackwardTrigger = "" + " ===========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=/\(\(\\)\@/'] + \ }, + \ '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=## fold'], + \ }, + \ 'css': 0, + \ } + \} +endif " ===================LanguageServer================== -if has("win32") - let g:LanguageClient_serverCommands = { - \ 'cpp': ['clangd'], - \ } -else - let g:LanguageClient_serverCommands = { - \ 'cpp': ['cquery', - \ '--log-file=/tmp/cq.log', - \ '--init={"cacheDirectory":"/tmp/cquery/"}'] - \ } -end -nnoremap K :call LanguageClient#textDocument_hover() -nnoremap gd :call LanguageClient#textDocument_definition({'gotoCmd': 'tabedit'}) -nnoremap :call LanguageClient_contextMenu() -vnoremap :call LanguageClient_contextMenu() -nnoremap :call LanguageClient_textDocument_documentSymbol() +if !exists('g:vscode') + if has("win32") + let g:LanguageClient_serverCommands = { + \ 'cpp': ['clangd'], + \ } + else + let g:LanguageClient_serverCommands = { + \ 'cpp': ['cquery', + \ '--log-file=/tmp/cq.log', + \ '--init={"cacheDirectory":"/tmp/cquery/"}'] + \ } + end + nnoremap K :call LanguageClient#textDocument_hover() + nnoremap gd :call LanguageClient#textDocument_definition({'gotoCmd': 'tabedit'}) + nnoremap :call LanguageClient_contextMenu() + vnoremap :call LanguageClient_contextMenu() + nnoremap :call LanguageClient_textDocument_documentSymbol() -let g:LanguageClient_hasClientSupport = 0 -" ===================EchoDoc========================= -set cmdheight=2 -let g:echodoc#enable_at_startup = 1 -let g:echodoc#type = 'signature' + let g:LanguageClient_hasClientSupport = 0 + " ===================EchoDoc========================= + set cmdheight=2 + let g:echodoc#enable_at_startup = 1 + let g:echodoc#type = 'signature' +endif " ===================FZF============================= -nnoremap :FZF -let g:fzf_action = { - \ 'enter': 'tab split', - \ 'ctrl-x': 'split', - \ 'ctrl-v': 'vsplit' } +if !exists('g:vscode') + nnoremap :FZF + let g:fzf_action = { + \ 'enter': 'tab split', + \ 'ctrl-x': 'split', + \ 'ctrl-v': 'vsplit' } +endif " ===================Chromatica====================== -let g:chromatica#enable_at_startup=1 +if !exists('g:vscode') + let g:chromatica#enable_at_startup=1 +endif " ===================COC============================= -inoremap coc#refresh() -autocmd CursorHold * silent call CocActionAsync('highlight') -set updatetime=500 " After ms should CursorHold trigger -" Remap for format selected region -vmap f (coc-format-selected) -nmap f (coc-format-selected) +if !exists('g:vscode') + inoremap coc#refresh() + autocmd CursorHold * silent call CocActionAsync('highlight') + set updatetime=500 " After ms should CursorHold trigger + " Remap for format selected region + vmap f (coc-format-selected) + nmap f (coc-format-selected) nmap r (coc-rename) " Use `:Format` for format current buffer @@ -298,8 +323,10 @@ endfunction nnoremap y :CocList -A --normal yank " ===================Denite========================== -call denite#custom#map('insert', '', '', 'noremap') -call denite#custom#map('insert', '', '', 'noremap') +if !exists('g:vscode') + call denite#custom#map('insert', '', '', 'noremap') + call denite#custom#map('insert', '', '', 'noremap') -nnoremap :Denite -default-action=tabopen file/rec -nnoremap :Denite buffer + nnoremap :Denite -default-action=tabopen file/rec + nnoremap :Denite buffer +endif