From 02c74099571c86d837b04db5b4b0874ad9041c2b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Wed, 1 Jun 2022 14:59:16 +0300 Subject: [PATCH] Switched vim with neovim. and updated: - shell functions - vim plugins - ansible tweaks - added alias `vim=nvim` - Updated theme to gruvbox --- files/dotfiles/alacritty.yml | 2 +- files/dotfiles/shellconfig/common.sh | 11 ++-- files/dotfiles/vimrc | 83 ++++++++++++++++---------- playbooks/cli-tools.yml | 3 +- playbooks/self-managed-unix-update.yml | 1 + playbooks/workstation.yml | 2 +- roles/vim_user/tasks/main.yml | 22 ++++--- 7 files changed, 75 insertions(+), 49 deletions(-) diff --git a/files/dotfiles/alacritty.yml b/files/dotfiles/alacritty.yml index 42a4037..0820549 100644 --- a/files/dotfiles/alacritty.yml +++ b/files/dotfiles/alacritty.yml @@ -319,4 +319,4 @@ schemes: white: '#aeb3bb' draw_bold_text_with_bright_colors: true -colors: *nord +colors: *gruvbox diff --git a/files/dotfiles/shellconfig/common.sh b/files/dotfiles/shellconfig/common.sh index 657f66d..a66c87c 100644 --- a/files/dotfiles/shellconfig/common.sh +++ b/files/dotfiles/shellconfig/common.sh @@ -13,6 +13,7 @@ alias :Q=exit alias ls='lsd' alias f='printf "\033c"' alias top=btm +alias vim=nvim alias t=tmux @@ -74,9 +75,6 @@ function huh() { echo Remotes:; \ echo -=-=-=-=; \ git remote -v | cat; \ - echo;echo Files:; \ - echo -=-=-=; \ - ls -l; \ echo;echo; } @@ -118,9 +116,10 @@ function ide() { tmux split-window -h -p 80 tmux split-window -h -p 30 tmux send-keys "gitui" C-m - tmux select-pane -t 1 - tmux split-window -v -p 20 - tmux select-pane -t 1 + tmux split-window -v + tmux select-pane -t 0 + tmux split-window -v + tmux select-pane -t 2 tmux send-keys "vim" C-m tmux rename-window ${IDE_NAME} } diff --git a/files/dotfiles/vimrc b/files/dotfiles/vimrc index 8f4c314..e9115fb 100644 --- a/files/dotfiles/vimrc +++ b/files/dotfiles/vimrc @@ -4,30 +4,31 @@ " plugins list call plug#begin('~/.vim/plugged') - Plug 'sheerun/vim-polyglot' " A ton of language syntax + Plug 'sheerun/vim-polyglot' " A ton of language syntax Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' } " Markdown Preview - Plug 'morhetz/gruvbox' " Gruvbox theme - Plug 'chriskempson/base16-vim' " Base 16 Themes - https://github.com/chriskempson/base16-vim - Plug 'sickill/vim-monokai' " Monokai Theme - Plug 'arcticicestudio/nord-vim' " Nord theme - Plug 'itchyny/lightline.vim' " vim status bar - Plug 'shinchu/lightline-gruvbox.vim' " Gruvbox theme for status line - Plug 'airblade/vim-gitgutter' " Git gutter - Plug 'zivyangll/git-blame.vim' " Git blame - Plug 'lilydjwg/colorizer' " Displays the colors in file - Plug 'jiangmiao/auto-pairs' " Auto create bracket/parens/quote pairs - Plug 'vim-syntastic/syntastic' " coding-errors checker - Plug 'puremourning/vimspector' " Multi lang Debugger - Plug 'neoclide/coc.nvim', {'branch': 'release'} " Lanuage server integrations - Plug 'tpope/vim-fugitive' " git wrapper - Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " golang plugin for vim - Plug 'Yggdroot/indentLine' " Indentation LInes - Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Install fzf - Plug 'junegunn/fzf.vim' " Fuzzy search - Plug 'francoiscabrol/ranger.vim' " Ranger f - Plug 'scrooloose/nerdtree' " NerdTree - File tree (ctr-n) - Plug 'Xuyuanp/nerdtree-git-plugin' " Git support in NERDTree - Plug 'ryanoasis/vim-devicons' " File Icons - Always load last + Plug 'pearofducks/ansible-vim' " Ansible support + Plug 'morhetz/gruvbox' " Gruvbox theme + Plug 'chriskempson/base16-vim' " Base 16 Themes - https://github.com/chriskempson/base16-vim + Plug 'sickill/vim-monokai' " Monokai Theme + Plug 'arcticicestudio/nord-vim' " Nord theme + Plug 'itchyny/lightline.vim' " vim status bar + Plug 'danilamihailov/beacon.nvim' " see cursor jumps easier + Plug 'shinchu/lightline-gruvbox.vim' " Gruvbox theme for status line + Plug 'lewis6991/gitsigns.nvim' " Git gutter and sings + Plug 'zivyangll/git-blame.vim' " Git blame + Plug 'lilydjwg/colorizer' " Displays the colors in file + Plug 'jiangmiao/auto-pairs' " Auto create bracket/parens/quote pairs + Plug 'vim-syntastic/syntastic' " coding-errors checker + Plug 'puremourning/vimspector' " Multi lang Debugger + Plug 'neoclide/coc.nvim', {'branch': 'release'} " Lanuage server integrations + Plug 'tpope/vim-fugitive' " git wrapper + Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } " golang plugin for vim + Plug 'Yggdroot/indentLine' " Indentation LInes + Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } " Install fzf + Plug 'junegunn/fzf.vim' " Fuzzy search + Plug 'francoiscabrol/ranger.vim' " Ranger f + Plug 'kyazdani42/nvim-web-devicons' " for file icons + Plug 'kyazdani42/nvim-tree.lua' " File tree/browser call plug#end() " Eliminate delay for esc insert->normal @@ -52,9 +53,14 @@ autocmd VimEnter * \ > len(filter(values(g:plugs), 'stridx(v:val.dir, g:plug_home) == 0')) \| PlugClean | q \| endif - +" Initiate lua +lua require('gitsigns').setup() +" Init NvimTree +lua require'nvim-tree'.setup {} " Toggle NerdTree with Ctrl+n -map :NERDTreeToggle +nnoremap :NvimTreeToggle +nnoremap r :NvimTreeRefresh +nnoremap n :NvimTreeFindFile " Open fzf Files search Ctrl+p map :Files " Open file search Ctrl+f @@ -79,8 +85,17 @@ imap " Set line heighlight on by default set cursorline -" Set Clipboard to system -set clipboard=unnamedplus +" Copy to clipboard +vnoremap y "+y +nnoremap Y "+yg_ +nnoremap y "+y +nnoremap yy "+yy + +" Paste from clipboard +nnoremap p "+p +nnoremap P "+P +vnoremap p "+p +vnoremap P "+P " Enable mouse use in all modes set mouse=a " Auto highlight similar words when staying on a word after .5 sec @@ -88,12 +103,16 @@ set updatetime=500 augroup highlight_current_word au! au CursorHold * - \ if ( expand("%") != 'NERD_tree_1' ) + \ if ( expand("%") != 'NvimTree_1' ) \ | :silent! :exec 'match Search /\V\<' . expand('') . '\>/' \ | endif augroup END +"============================================================================== +" Beacon settings +"============================================================================== +let g:beacon_minimal_jump = 1 "============================================================================== " Sync NERDTree with file "============================================================================== @@ -127,9 +146,9 @@ let &t_8f = "\[38;2;%lu;%lu;%lum" let &t_8b = "\[48;2;%lu;%lu;%lum" set termguicolors " Theme -colorscheme nord +colorscheme gruvbox " Setting dark mode -set background=dark +" set background=dark "============================================================================== " line number @@ -146,7 +165,7 @@ set background=dark :augroup END " Set current line number more visible -hi clear CursorLine +" hi clear CursorLine augroup CLClear autocmd! ColorScheme * hi clear CursorLine augroup END @@ -314,7 +333,7 @@ let g:lightline = { \ }, \ } " lightline colorscheme -" let g:lightline.colorscheme = 'nord' +" let g:lightline.colorscheme = 'gruvbox' " function to get the filename from vim to lightline.vim function! LightlineFilename() return &filetype ==# 'vimfiler' ? vimfiler#get_status_string() : diff --git a/playbooks/cli-tools.yml b/playbooks/cli-tools.yml index 156d5dd..0d4e712 100644 --- a/playbooks/cli-tools.yml +++ b/playbooks/cli-tools.yml @@ -1,8 +1,9 @@ - hosts: localhost + connection: local name: CLI tools Playbook vars: # Theme options: monokai, gruvbox, nord, tomorrow-night - theme: tomorrow-night + theme: gruxbox # The running user running_user: "{{ ansible_user_id }}" roles: diff --git a/playbooks/self-managed-unix-update.yml b/playbooks/self-managed-unix-update.yml index d2d097c..f5663fe 100644 --- a/playbooks/self-managed-unix-update.yml +++ b/playbooks/self-managed-unix-update.yml @@ -1,4 +1,5 @@ - hosts: localhost + connection: local name: Self managed modern UNIX tools vars: # Theme options: monokai, gruvbox, nord, tomorrow-night diff --git a/playbooks/workstation.yml b/playbooks/workstation.yml index 3cddde0..926375e 100644 --- a/playbooks/workstation.yml +++ b/playbooks/workstation.yml @@ -2,7 +2,7 @@ name: Workstation Playbook vars: # Theme options: monokai, gruvbox, nord, tomorrow-night - theme: tomorrow-night + theme: gruvbox # The running user running_user: "{{ ansible_user_id }}" roles: diff --git a/roles/vim_user/tasks/main.yml b/roles/vim_user/tasks/main.yml index a5a019f..8251985 100644 --- a/roles/vim_user/tasks/main.yml +++ b/roles/vim_user/tasks/main.yml @@ -2,7 +2,7 @@ become: true package: name: - - vim + - neovim - the_silver_searcher state: present when: ansible_facts['os_family'] == "RedHat" @@ -11,34 +11,40 @@ become: true package: name: - - vim + - neovim - silversearcher-ag state: present when: ansible_facts['os_family'] == "Debian" -- name: Prepare vim... +- name: Prepare vim config directory file: - path: ~/.vim/autoload + path: ~/.config/nvim/ + state: directory + mode: '0755' + +- name: Setup vim plug + file: + path: ~/.local/share/nvim/site/autoload state: directory mode: '0755' - name: Install vim Plug get_url: url: https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim - dest: ~/.vim/autoload/plug.vim + dest: ~/.local/share/nvim/site/autoload/plug.vim - name: "Copy vimrc file" copy: src: dotfiles/vimrc - dest: "~/.vimrc" + dest: "~/.config/nvim/init.vim" mode: preserve changed_when: false - name: "Set vim colorscheme" ansible.builtin.lineinfile: - path: "~/.vimrc" + path: "~/.config/nvim/init.vim" regexp: "^colorscheme" - line: "colorscheme base16-{{ theme }}" + line: "colorscheme {{ theme }}" changed_when: false #- name: "Set vim lightline colorscheme"