summaryrefslogtreecommitdiff
path: root/.config/nvim
diff options
context:
space:
mode:
authoraktersnurra <grydholm@kth.se>2021-02-10 23:52:57 +0100
committeraktersnurra <grydholm@kth.se>2021-02-10 23:52:57 +0100
commit007971825506ece9bc462a22b751b8d670e2bd01 (patch)
tree4b7bbdbc9a464b4440b6f67c63c601184c35733e /.config/nvim
parentaa2b6faa6c52e3c333d3cc5f47dad0391085e666 (diff)
fzf working
Diffstat (limited to '.config/nvim')
-rw-r--r--.config/nvim/README.md20
-rw-r--r--.config/nvim/init.vim2
-rw-r--r--.config/nvim/plug-config/fzf.vim78
-rw-r--r--.config/nvim/plug-config/vim-rooter.vim1
-rw-r--r--.config/nvim/vim-plug/plugins.vim10
5 files changed, 110 insertions, 1 deletions
diff --git a/.config/nvim/README.md b/.config/nvim/README.md
new file mode 100644
index 0000000..f70cefd
--- /dev/null
+++ b/.config/nvim/README.md
@@ -0,0 +1,20 @@
+# Neovim
+
+## Requirements
+Must have neovim >= 0.5
+
+## Installation
+
+### Ranger
+
+pip3 install ranger-fm pynvim
+
+### fzf
+
+Depending on OS:
+
+* brew install fzf
+
+* sudo apt install fzf
+
+* sudo pacman -S fzf
diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim
index e979a84..fe5128a 100644
--- a/.config/nvim/init.vim
+++ b/.config/nvim/init.vim
@@ -13,6 +13,8 @@ source $HOME/.config/nvim/plug-config/rnvimr.vim
source $HOME/.config/nvim/plug-config/ranger.vim
source $HOME/.config/nvim/plug-config/barbar.vim
source $HOME/.config/nvim/plug-config/floaterm.vim
+source $HOME/.config/nvim/plug-config/fzf.vim
+source $HOME/.config/nvim/plug-config/vim-rooter.vim
" Theme
diff --git a/.config/nvim/plug-config/fzf.vim b/.config/nvim/plug-config/fzf.vim
new file mode 100644
index 0000000..fbb5457
--- /dev/null
+++ b/.config/nvim/plug-config/fzf.vim
@@ -0,0 +1,78 @@
+" This is the default extra key bindings
+let g:fzf_action = {
+ \ 'ctrl-t': 'tab split',
+ \ 'ctrl-x': 'split',
+ \ 'ctrl-v': 'vsplit' }
+
+" Enable per-command history.
+" CTRL-N and CTRL-P will be automatically bound to next-history and
+" previous-history instead of down and up. If you don't like the change,
+" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS.
+let g:fzf_history_dir = '~/.local/share/fzf-history'
+let g:fzf_buffers_jump = 1
+
+" map <C-f> :Files<CR>
+" map <leader>b :Buffers<CR>
+" nnoremap <leader>g :Rg<CR>
+" nnoremap <leader>t :Tags<CR>
+" nnoremap <leader>m :Marks<CR>
+
+
+let g:fzf_tags_command = 'ctags -R'
+" Border color
+let g:fzf_layout = {'up':'~90%', 'window': { 'width': 0.8, 'height': 0.8,'yoffset':0.5,'xoffset': 0.5, 'highlight': 'Todo', 'border': 'sharp' } }
+
+let $FZF_DEFAULT_OPTS = '--layout=reverse --inline-info'
+let $FZF_DEFAULT_COMMAND="rg --files --hidden --glob '!.git/**'"
+"-g '!{node_modules,.git}'
+
+" Customize fzf colors to match your color scheme
+let g:fzf_colors =
+\ { 'fg': ['fg', 'Normal'],
+ \ 'bg': ['bg', 'Normal'],
+ \ 'hl': ['fg', 'Comment'],
+ \ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
+ \ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
+ \ 'hl+': ['fg', 'Statement'],
+ \ 'info': ['fg', 'PreProc'],
+ \ 'border': ['fg', 'Ignore'],
+ \ 'prompt': ['fg', 'Conditional'],
+ \ 'pointer': ['fg', 'Exception'],
+ \ 'marker': ['fg', 'Keyword'],
+ \ 'spinner': ['fg', 'Label'],
+ \ 'header': ['fg', 'Comment'] }
+
+"Get Files
+command! -bang -nargs=? -complete=dir Files
+ \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': ['--layout=reverse', '--inline-info']}), <bang>0)
+
+
+" Get text in files with Rg
+" command! -bang -nargs=* Rg
+" \ call fzf#vim#grep(
+" \ "rg --column --line-number --no-heading --color=always --smart-case --glob '!.git/**' ".shellescape(<q-args>), 1,
+
+ " Make Ripgrep ONLY search file contents and not filenames
+command! -bang -nargs=* Rg
+ \ call fzf#vim#grep(
+ \ 'rg --column --line-number --hidden --smart-case --no-heading --color=always '.shellescape(<q-args>), 1,
+ \ <bang>0 ? fzf#vim#with_preview({'options': '--delimiter : --nth 4..'}, 'up:60%')
+ \ : fzf#vim#with_preview({'options': '--delimiter : --nth 4.. -e'}, 'right:50%', '?'),
+ \ <bang>0)
+
+" Ripgrep advanced
+function! RipgrepFzf(query, fullscreen)
+ let command_fmt = 'rg --column --line-number --no-heading --color=always --smart-case %s || true'
+ let initial_command = printf(command_fmt, shellescape(a:query))
+ let reload_command = printf(command_fmt, '{q}')
+ let spec = {'options': ['--phony', '--query', a:query, '--bind', 'change:reload:'.reload_command]}
+ call fzf#vim#grep(initial_command, 1, fzf#vim#with_preview(spec), a:fullscreen)
+endfunction
+
+command! -nargs=* -bang RG call RipgrepFzf(<q-args>, <bang>0)
+
+" Git grep
+command! -bang -nargs=* GGrep
+ \ call fzf#vim#grep(
+ \ 'git grep --line-number '.shellescape(<q-args>), 0,
+ \ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
diff --git a/.config/nvim/plug-config/vim-rooter.vim b/.config/nvim/plug-config/vim-rooter.vim
new file mode 100644
index 0000000..0fea077
--- /dev/null
+++ b/.config/nvim/plug-config/vim-rooter.vim
@@ -0,0 +1 @@
+let g:rooter_silent_chdir = 1
diff --git a/.config/nvim/vim-plug/plugins.vim b/.config/nvim/vim-plug/plugins.vim
index c4e683a..30d14a4 100644
--- a/.config/nvim/vim-plug/plugins.vim
+++ b/.config/nvim/vim-plug/plugins.vim
@@ -22,21 +22,29 @@ call plug#begin('~/.config/nvim/autoload/plugged')
Plug 'synul/githubsy'
Plug 'dylanaraps/wal.vim'
Plug 'richtan/pywal.vim'
+ " FZF
+ Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
+ Plug 'junegunn/fzf.vim'
+ Plug 'airblade/vim-rooter'
" Better tabline
Plug 'romgrk/barbar.nvim'
- " Terminal
+
+ " Terminal
Plug 'voldikss/vim-floaterm'
+
" Status line
" Plug 'vim-airline/vim-airline'
" Plug 'vim-airline/vim-airline-themes'
Plug 'glepnir/galaxyline.nvim' , {'branch': 'main'}
" Vista
Plug 'liuchengxu/vista.vim'
+
" If you want icons use one of these:
Plug 'kyazdani42/nvim-web-devicons' " lua
Plug 'ryanoasis/vim-devicons' " vimscript
Plug 'kyazdani42/nvim-tree.lua'
+
" Stable version of coc
Plug 'neoclide/coc.nvim', {'branch': 'release'}