Better terminal editing experience

* Decrease alacritty font size
* Improve file previews in fzf-nvim by removing some copyright notices
* Use reverse layout in fzf-nvim to align with zsh file completion
This commit is contained in:
Benjamin Bädorf 2021-11-29 19:06:10 +01:00
parent 65c8894f47
commit b5500d5e9e
No known key found for this signature in database
GPG key ID: 4406E80E13CD656C
5 changed files with 78 additions and 42 deletions

View file

@ -55,7 +55,7 @@
style = "Italic"; style = "Italic";
}; };
size = 18.0; size = 16.0;
offset = { offset = {
x = 0; x = 0;

View file

@ -3,6 +3,8 @@ let
psCfg = config.pub-solar; psCfg = config.pub-solar;
xdg = config.home-manager.users."${psCfg.user.name}".xdg; xdg = config.home-manager.users."${psCfg.user.name}".xdg;
preview-file = pkgs.writeShellScriptBin "preview-file" (import ./preview-file.nix pkgs);
sonokai = pkgs.vimUtils.buildVimPlugin { sonokai = pkgs.vimUtils.buildVimPlugin {
name = "sonokai"; name = "sonokai";
src = pkgs.fetchFromGitHub { src = pkgs.fetchFromGitHub {
@ -66,6 +68,11 @@ in
(builtins.readFile ./ui.vim) (builtins.readFile ./ui.vim)
(builtins.readFile ./quickfixopenall.vim) (builtins.readFile ./quickfixopenall.vim)
(builtins.readFile ./lsp.vim) (builtins.readFile ./lsp.vim)
''
" fzf with file preview
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, { 'options': ['--keep-right', '--cycle', '--layout', 'reverse', '--preview', '${preview-file}/bin/preview-file {}'] }, <bang>0)
''
]; ];
extraPackages = with pkgs; [ extraPackages = with pkgs; [
@ -93,6 +100,9 @@ in
]; ];
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; [
# Lua async programming library
plenary-nvim
completion-nvim completion-nvim
lsp_extensions-nvim lsp_extensions-nvim
nvim-lspconfig nvim-lspconfig

View file

@ -94,47 +94,6 @@ imap <c-x><c-l> <plug>(fzf-complete-line)
" Clear quickfix shortcut " Clear quickfix shortcut
nmap <Leader>c :ccl<CR> nmap <Leader>c :ccl<CR>
" netrw
let g:netrw_fastbrowse=0
" fzf with file preview
command! -bang -nargs=? -complete=dir Files
\ call fzf#vim#files(<q-args>, fzf#vim#with_preview(), <bang>0)
"command! -bang -nargs=? -complete=dir Files
" \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': '--preview "' . "grep -Pzo '.*See docs/COPYRIGHT.rdoc for more details(.*\n)*' {}" . '"'}), <bang>0)
" Auto-FMT rust code on save
let g:rustfmt_autosave = 1
" Indenting in html template tags
let g:html_indent_style1 = "inc"
" yank highlight duration
let g:highlightedyank_highlight_duration = 200
" Markdown options
let g:vim_markdown_folding_disabled = 1
" Haskell options
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
" Emmet
let g:user_emmet_leader_key='<c-n>'
" Minimap settings
let g:minimap_auto_start = 1
" Ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
" Remember cursor position " Remember cursor position
" Vim jumps to the last position when reopening a file " Vim jumps to the last position when reopening a file
if has("autocmd") if has("autocmd")

View file

@ -41,3 +41,35 @@ nnoremap <leader>gP :! git push<CR> " git Push
" http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/ " http://vimcasts.org/episodes/fugitive-vim-resolving-merge-conflicts-with-vimdiff/
nmap <Leader>[ :diffget //2<CR> nmap <Leader>[ :diffget //2<CR>
nmap <Leader>] :diffget //3<CR> nmap <Leader>] :diffget //3<CR>
" netrw
let g:netrw_fastbrowse=0
" Auto-FMT rust code on save
let g:rustfmt_autosave = 1
" Indenting in html template tags
let g:html_indent_style1 = "inc"
" yank highlight duration
let g:highlightedyank_highlight_duration = 200
" Markdown options
let g:vim_markdown_folding_disabled = 1
" Haskell options
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
" Emmet
let g:user_emmet_leader_key='<c-n>'
" Ack
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif

View file

@ -0,0 +1,35 @@
self: with self; ''
IFS=':' read -r -a INPUT <<< "$1"
FILE=''${INPUT[0]}
CENTER=''${INPUT[1]}
if [[ "$1" =~ ^[A-Za-z]:\\ ]]; then
FILE=$FILE:''${INPUT[1]}
CENTER=''${INPUT[2]}
fi
if [[ -n "$CENTER" && ! "$CENTER" =~ ^[0-9] ]]; then
exit 1
fi
CENTER=''${CENTER/[^0-9]*/}
FILE="''${FILE/#\~\//$HOME/}"
if [ ! -r "$FILE" ]; then
echo "File not found ''${FILE}"
exit 1
fi
if [ -z "$CENTER" ]; then
CENTER=0
fi
exec cat "$FILE" \
| sed -e '/[#|\/\/ ?]-- copyright/,/[#\/\/]++/c\\' \
| ${pkgs.coreutils}/bin/tr -s '\n' \
| ${pkgs.bat}/bin/bat \
--style="''${BAT_STYLE:-numbers}" \
--color=always \
--pager=never \
--file-name=''$FILE \
--highlight-line=$CENTER
''