From cf9e26041fbc36047b4c0cfed5eb0ea925524203 Mon Sep 17 00:00:00 2001 From: Jeff LANCE Date: Tue, 5 Nov 2019 09:58:19 +0100 Subject: [PATCH] Add a new command and script to open a file via dmenu app --- vim/vim/keybindings.vim | 6 ++++++ vim/vim/scripts.vim | 27 +++++++++++++++++++++++++++ vim/vimrc | 25 +++++++++++++++++++++---- 3 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 vim/vim/scripts.vim diff --git a/vim/vim/keybindings.vim b/vim/vim/keybindings.vim index 52b3a0a..c49b1b8 100644 --- a/vim/vim/keybindings.vim +++ b/vim/vim/keybindings.vim @@ -24,3 +24,9 @@ map :NERDTreeToggle let g:UltiSnipsExpandTrigger="" let g:UltiSnipsJumpForwardTrigger="" let g:UltiSnipsJumpBackwardTrigger="" + +" +" DMenu file opening +" +map :call DmenuOpen("tabe") +map :call DmenuOpen("e") diff --git a/vim/vim/scripts.vim b/vim/vim/scripts.vim new file mode 100644 index 0000000..2785f8e --- /dev/null +++ b/vim/vim/scripts.vim @@ -0,0 +1,27 @@ +""""""""""""""""""""""""""""""""""""""""""" +" ____ ____ ____ ___ ____ _____ ____ +" / ___| / ___| _ \|_ _| _ \_ _/ ___| +" \___ \| | | |_) || || |_) || | \___ \ +" ___) | |___| _ < | || __/ | | ___) | +:" |____/ \____|_| \_\___|_| |_| |____/ +" +""""""""""""""""""""""""""""""""""""""""""" +" +" File opening scripts using DMenu +" +" Strip the newline from the end of a string +function! Chomp(str) + return substitute(a:str, '\n$', '', '') +endfunction + +" Find a file and pass it to cmd +function! DmenuOpen(cmd) + let fname = Chomp(system("git ls-files | dmenu -i -l 20 -p " . a:cmd)) + if empty(fname) + return + endif + execute a:cmd . " " . fname +endfunction + + + diff --git a/vim/vimrc b/vim/vimrc index 4a08f9c..876fd84 100644 --- a/vim/vimrc +++ b/vim/vimrc @@ -32,7 +32,7 @@ set nowrap cnoremap w!! w !sudo tee > /dev/null % " Start in insert mode for ALL files -"au BufRead,BufNewFile * startinsert +au BufRead,BufNewFile * startinsert "startinsert @@ -75,10 +75,14 @@ let g:lightline = { \ 'colorscheme': 'jellybeans', \ 'active': { \ 'left': [ [ 'mode', 'paste' ], - \ [ 'readonly', 'filename', 'modified' ] ] + \ [ 'readonly', 'filename', 'modified' ] ], + \ 'right': [ [ 'lineinfo' ], + \ [ 'percent' ], + \ [ 'fileformat', 'fileencoding', 'filetype', 'kitestatus' ] ], \ }, \ 'component': { \ 'readonly': '%{&readonly?"⭤":""}', + \ 'kitestatus': '%{kite#statusline()}', \ }, \ 'separator': { 'left': '⮀', 'right': '⮂' }, \ 'subseparator': { 'left': '⮁', 'right': '⮃' } @@ -125,13 +129,26 @@ endif -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +""""""""""""""""""""""""""""""""""""""""""" +" ____ ____ ____ ___ ____ _____ ____ +" / ___| / ___| _ \|_ _| _ \_ _/ ___| +" \___ \| | | |_) || || |_) || | \___ \ +" ___) | |___| _ < | || __/ | | ___) | +" |____/ \____|_| \_\___|_| |_| |____/ +" +""""""""""""""""""""""""""""""""""""""""""" +" Load scripts from file +source $HOME/.vim/scripts.vim + + + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " _ _________ ______ ___ _ _ ____ ___ _ _ ____ ____ " | |/ / ____\ \ / / __ )_ _| \ | | _ \_ _| \ | |/ ___/ ___| " | ' /| _| \ V /| _ \| || \| | | | | || \| | | _\___ \ " | . \| |___ | | | |_) | || |\ | |_| | || |\ | |_| |___) | " |_|\_\_____| |_| |____/___|_| \_|____/___|_| \_|\____|____/ " -"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Load keybindings from file source $HOME/.vim/keybindings.vim