feat: add nnn and vim-floaterm

This commit is contained in:
Klesh Wong 2021-09-30 13:54:42 +08:00
parent ce6d71c5c4
commit e5f5d2c785
6 changed files with 119 additions and 3 deletions

3
bin/ns Executable file
View File

@ -0,0 +1,3 @@
#!/bin/sh
xargs -0 ls -l < "${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection"

View File

@ -13,7 +13,8 @@ if status is-interactive
# === less configuration
# no line-wrapping, good for `docker ps`
set -gx LESS "-SRXF"
#set -gx LESS "-SRXF"
set -gx LESS "-SRX" # for nnn help to how, remove F
# === nvm configuration
set -gx nvm_mirror http://npm.taobao.org/mirrors/node
@ -22,6 +23,9 @@ if status is-interactive
# change OTHER-WRITABLE color for `ls` command
set -gx LS_COLORS 'ow=34;42;40'
# === nnn configuration
set -gx NNN_PLUG 'c:fzcd;m:nmount;x:!chmod +x $nnn;d:dragdrop'
# === bat configuration
set -gx BAT_THEME 'OneHalfDark'
set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'"

37
cli/fish/functions/n.fish Normal file
View File

@ -0,0 +1,37 @@
# Rename this file to match the name of the function
# e.g. ~/.config/fish/functions/n.fish
# or, add the lines to the 'config.fish' file.
function n --wraps nnn --description 'support nnn quit and change directory'
# Block nesting of nnn in subshells
if test -n "$NNNLVL"
if [ (expr $NNNLVL + 0) -ge 1 ]
echo "nnn is already running"
return
end
end
# The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
# To cd on quit only on ^G, remove the "-x" as in:
# set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
# (or, to a custom path: set NNN_TMPFILE "/tmp/.lastd")
# or, export NNN_TMPFILE after nnn invocation
if test -n "$XDG_CONFIG_HOME"
set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
else
set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
end
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef
# stty stop undef
# stty lwrap undef
# stty lnext undef
nnn $argv
if test -e $NNN_TMPFILE
source $NNN_TMPFILE
rm $NNN_TMPFILE
end
end

22
cli/nnn.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
set -e
DIR=$(dirname "$(readlink -f "$0")")
. "$DIR/../env.sh"
log 'Setting up nnn'
# setup package mirror for CHINA
case "$PM" in
apt)
echo TODO
exit -1
;;
pacman)
sudo pacman -S --noconfirm --needed nnn
yay -S --noconfirm --needed dragon-drag-and-drop
esac
# configuration
lnsf "$DIR/nnn/n.fish" "$XDG_CONFIG_HOME/fish/functions/n.fish"
cp -r /usr/share/nnn/plugins/. "$XDG_CONFIG_HOME/nnn/plugins"

37
cli/nnn/n.fish Normal file
View File

@ -0,0 +1,37 @@
# Rename this file to match the name of the function
# e.g. ~/.config/fish/functions/n.fish
# or, add the lines to the 'config.fish' file.
function n --wraps nnn --description 'support nnn quit and change directory'
# Block nesting of nnn in subshells
if test -n "$NNNLVL"
if [ (expr $NNNLVL + 0) -ge 1 ]
echo "nnn is already running"
return
end
end
# The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
# To cd on quit only on ^G, remove the "-x" as in:
# set NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
# (or, to a custom path: set NNN_TMPFILE "/tmp/.lastd")
# or, export NNN_TMPFILE after nnn invocation
if test -n "$XDG_CONFIG_HOME"
set -x NNN_TMPFILE "$XDG_CONFIG_HOME/nnn/.lastd"
else
set -x NNN_TMPFILE "$HOME/.config/nnn/.lastd"
end
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef
# stty stop undef
# stty lwrap undef
# stty lnext undef
nnn $argv
if test -e $NNN_TMPFILE
source $NNN_TMPFILE
rm $NNN_TMPFILE
end
end

View File

@ -50,7 +50,7 @@ noremap <C-f> <Right>
noremap <C-b> <Left>
vnoremap <leader>p pgvy
nnoremap <leader>q :qall<CR>
nnoremap Q :qall<CR>
nnoremap <Leader>v <c-v>
nnoremap <Leader>s :b#<CR>
@ -68,6 +68,7 @@ nnoremap <leader>k <C-w>k
nnoremap <leader>l <C-w>l
nnoremap <leader>oo <C-w>o
nnoremap <leader>q <C-w>q
nnoremap <leader>x :!chmod +x %<Cr>
function! GetXCopyCmd()
@ -169,6 +170,7 @@ Plug 'alvan/vim-closetag'
"Plug 'francoiscabrol/ranger.vim'
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
Plug 'junegunn/fzf.vim'
Plug 'voldikss/vim-floaterm'
Plug 'preservim/nerdtree'
if $VIM_MODE == 'enhanced'
@ -367,9 +369,20 @@ highlight SpellBad gui=undercurl
" commitmsg
autocmd BufEnter,BufRead commitmsg.md :set colorcolumn=100
" nerdtree
" ==== nerdtree ====
nnoremap <leader>t :NERDTreeToggle<CR>
" go organize import on save
" ==== golang ====
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport')
autocmd BufWritePre *.go :OR
" ==== floaterm ====
nnoremap <leader>tt :FloatermNew nnn<CR>
let g:floaterm_autohide=1
let g:floaterm_autoclose=1
let g:floaterm_opener='edit'
let g:floaterm_keymap_new = '<F7>'
let g:floaterm_keymap_prev = '<F8>'
let g:floaterm_keymap_next = '<F9>'
let g:floaterm_keymap_toggle = '<F12>'