Updated .vimrc

master
Ruben 2022-12-30 09:19:24 +01:00
parent bf453117cc
commit 4db3b806a9
No known key found for this signature in database
GPG Key ID: F6DAAC2742760162
1 changed files with 71 additions and 15 deletions

78
.vimrc
View File

@ -1,4 +1,4 @@
set cursorline " set cursorline
set wildmenu set wildmenu
set incsearch set incsearch
set hlsearch set hlsearch
@ -10,45 +10,66 @@ set autoindent
set textwidth=80 set textwidth=80
set noshowmode set noshowmode
set expandtab set expandtab
set smarttab
set smartindent
set smartcase
set ignorecase
set backspace=indent,eol,start
syntax on syntax on
set nocompatible set nocompatible
let mapleader=" " let mapleader=" "
filetype off filetype off
set path+=/usr/include/nodejs/src/
set rtp+=~/.vim/bundle/Vundle.vim set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin() call vundle#begin()
Plugin 'VundleVim/Vundle.vim' Plugin 'VundleVim/Vundle.vim'
Plugin 'preservim/nerdtree' Plugin 'preservim/nerdtree'
Plugin 'preservim/nerdcommenter'
Plugin 'joshdick/onedark.vim' Plugin 'joshdick/onedark.vim'
Plugin 'w0rp/ale' Plugin 'w0rp/ale'
Plugin 'tiagofumo/vim-nerdtree-syntax-highlight' Plugin 'tiagofumo/vim-nerdtree-syntax-highlight'
Plugin 'ryanoasis/vim-devicons' Plugin 'ryanoasis/vim-devicons'
Plugin 'airblade/vim-gitgutter' Plugin 'airblade/vim-gitgutter'
Plugin 'ctrlpvim/ctrlp.vim' Plugin 'ctrlpvim/ctrlp.vim'
Plugin 'github/copilot.vim' Plugin 'preservim/nerdcommenter'
Plugin 'HerringtonDarkholme/yats.vim'
Plugin 'mhinz/vim-startify'
Plugin 'sbdchd/neoformat'
Plugin 'Raimondi/delimitMate'
Plugin 'itchyny/lightline.vim' Plugin 'itchyny/lightline.vim'
Plugin 'github/copilot.vim'
call vundle#end() call vundle#end()
filetype plugin indent on filetype plugin indent on
" NERDTree " Opens NERDTree when a directory is opened
autocmd StdinReadPre * let s:std_in=1 autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | exe 'NERDTree' | wincmd p | ene | exe 'cd '.argv()[0] | endif autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif
" Exit NERDTree if all files have closed
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Check if NERDTree is open or active
function! IsNERDTreeOpen() function! IsNERDTreeOpen()
return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1) return exists("t:NERDTreeBufName") && (bufwinnr(t:NERDTreeBufName) != -1)
endfunction endfunction
" Call NERDTreeFind if NERDTree is active, current window contains a modifiable
" file and we're not in vimdiff
function! s:synctree()
if &modifiable && IsNERDTreeOpen() && strlen(expand('%')) > 0 && !&diff
nerdtreefind
wincmd p
endif
endfunction
function s:refresh()
if IsNERDTreeOpen()
exec "NERDTreeRefreshRoot"
exec "NERDTreeRefreshRoot"
endif
endfunction
map <silent> <F5> :call <SID>refresh()<CR>
set hidden set hidden
set updatetime=300 set updatetime=300
set signcolumn=yes set signcolumn=yes
@ -82,16 +103,42 @@ let g:NERDTrimTrailingWhitespace = 1
" Enable NERDCommenterToggle to check all selected lines is commented or not " Enable NERDCommenterToggle to check all selected lines is commented or not
let g:NERDToggleCheckAllLines = 1 let g:NERDToggleCheckAllLines = 1
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ale_linters_explicit = 1 let g:ale_linters_explicit = 1
let g:ale_linters = { 'cpp': ['g++'], 'c': ['gcc'] } let g:ale_linters = { 'cpp': ['g++'], 'c': ['gcc'] }
let g:ale_cpp_cc_options = "-std=c++17" let g:ale_cpp_cc_options = "-std=c++17"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Autoformat with clang-format
function! FormatOnSave()
let l:formatdiff = 1
pyf ~/.local/bin/clang-format.py
endfunction
autocmd BufWritePre *.h,*.cc,*.cpp,*.c call FormatOnSave()
autocmd BufWritePre,InsertLeave *.js Neoformat
au BufNewFile,BufRead *.ejs set filetype=html
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
nnoremap <silent> K :call <SID>show_documentation()<CR>
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
noremap <silent> <expr> j (v:count == 0 ? 'gj' : 'j')
noremap <silent> <expr> k (v:count == 0 ? 'gk' : 'k')
map <C-n> :NERDTreeToggle<CR>
inoremap jk <ESC> inoremap jk <ESC>
vmap <C-m> <Plug>NERDCommenterToggle vmap <C-m> <Plug>NERDCommenterToggle
nmap <C-m> <Plug>NERDCommenterToggle nmap <C-m> <Plug>NERDCommenterToggle
nnoremap <C-h> <C-w><C-h>
nnoremap <C-j> <C-w><C-j>
nnoremap <C-k> <C-w><C-k>
nnoremap <C-l> <C-w><C-l>
nnoremap ,<space> :nohlsearch<CR>
if (has("nvim")) if (has("nvim"))
"For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 > "For Neovim 0.1.3 and 0.1.4 < https://github.com/neovim/neovim/pull/2198 >
@ -112,5 +159,14 @@ let g:lightline = {
\ 'colorscheme': 'onedark', \ 'colorscheme': 'onedark',
\ } \ }
" Python tab fix
function! s:fixtab()
set expandtab
set tabstop=4
retab
endfunction
command FixTab :call s:fixtab()
syntax on syntax on
colorscheme onedark colorscheme onedark