diff options
| -rw-r--r-- | .config/nvim/autoload/projector.vim | 42 | ||||
| -rw-r--r-- | .config/nvim/init.vim | 23 | ||||
| -rw-r--r-- | .profile | 1 |
3 files changed, 51 insertions, 15 deletions
diff --git a/.config/nvim/autoload/projector.vim b/.config/nvim/autoload/projector.vim new file mode 100644 index 0000000..9c60055 --- /dev/null +++ b/.config/nvim/autoload/projector.vim @@ -0,0 +1,42 @@ +" Allows per-project configuration of keybindings. +" For example, '*.cpp <F5> make' will run make on F5 button push +" if .cpp file was opened +let s:commandFormat="au BufReadPost,BufNewFile %s map %s :!%s<CR>" + +" Files that plugin searches on startup (relative to pwd) +let s:allowedConfigPaths=[".vim/config", ".vim.conf", "vim.conf"] + +function! s:createCommand(line) + let line=split(a:line) + return printf(s:commandFormat, line[0], line[1], join(line[2:])) +endfunction + +function! s:parseFile(filename) + let commands=[] + for line in readfile(a:filename) + let commands=commands + [s:createCommand(line)] + endfor + return commands +endfunction + +function! s:getConfigs() + let commands=[] + for filename in s:allowedConfigPaths + if filereadable(filename) + let commands=commands + s:parseFile(filename) + endif + endfor + return commands +endfunction + +function! s:applyConfig(config) + for line in a:config + execute line + endfor +endfunction + +function! projector#init() + let config=s:getConfigs() + call s:applyConfig(config) +endfunction + diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 83308e4..69dd66d 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,17 +1,18 @@ set nocompatible filetype off +set rtp+=~/.config/nvim set rtp+=~/.config/nvim/bundle/Vundle.vim call vundle#begin('~/.config/nvim/bundle') Plugin 'VundleVim/Vundle.vim' -Plugin 'scrooloose/nerdtree' Plugin 'scrooloose/nerdcommenter' Plugin 'tpope/vim-fugitive' Plugin 'vim-airline/vim-airline' Plugin 'morhetz/gruvbox' Plugin 'junegunn/fzf', { 'do': { -> fzf#install() } } Plugin 'junegunn/fzf.vim' +Plugin 'loremipsum' call vundle#end() filetype plugin indent on @@ -22,6 +23,9 @@ set softtabstop=4 set shiftwidth=4 set expandtab set autochdir +set colorcolumn=80,120 +" set formatoptions-=t +set formatprg=par\ -w80 " Enable clipboard buffer to be used as vim buffer set clipboard=unnamedplus @@ -40,19 +44,6 @@ au InsertLeave * set relativenumber colorscheme gruvbox set background=dark -autocmd StdinReadPre * let s:std_in=1 - -" Open NERDTree if no file specified -" autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif - -" Open NERDTree if openning directory -" autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif - -" Close vim if only window left open is NERDTree -autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif - -map <C-n> :NERDTreeToggle<CR> - " Remap splits shortcuts nnoremap <C-J> <C-W><C-J> nnoremap <C-K> <C-W><C-K> @@ -73,5 +64,9 @@ vmap <C-\> <leader>c<space> autocmd VimEnter * let g:basedir=expand("%:p:h") nmap <C-p> :execute "Files" g:basedir<CR> +" Use of FZF plugin nmap ; :Buffers<CR> nmap <C-w> :bd!<CR> + +" Calling my script that allows per-project configuration of tasks keybindings +call projector#init() @@ -4,7 +4,6 @@ if [ -d "$HOME/.local/bin" ] ; then fi export SHELL="/bin/bash" -export VIMINIT="source $MYVIMRC" # For Jetbrains products export _JAVA_AWT_WM_NONREPARENTING=1 |