aboutsummaryrefslogtreecommitdiff
path: root/.vim
diff options
context:
space:
mode:
authorsrdusr <trevorgray@srdusr.com>2024-04-02 23:57:15 +0200
committersrdusr <trevorgray@srdusr.com>2024-04-02 23:57:15 +0200
commita328e06fc40857e846aa7815fcbbc4b5e39e8723 (patch)
tree682b7ab002c8d71148ea9d74999be0df3a517ab1 /.vim
parentb1718140df5f0ef72fe2b2d284f87ddaac802cb8 (diff)
downloaddotfiles-a328e06fc40857e846aa7815fcbbc4b5e39e8723.tar.gz
dotfiles-a328e06fc40857e846aa7815fcbbc4b5e39e8723.zip
Fixed tmux vi-mode messing up cmd mode with extra characters
Diffstat (limited to '.vim')
-rw-r--r--.vim/vimrc336
1 files changed, 53 insertions, 283 deletions
diff --git a/.vim/vimrc b/.vim/vimrc
index e00fdd8..ce034e9 100644
--- a/.vim/vimrc
+++ b/.vim/vimrc
@@ -30,9 +30,15 @@ map <leader>n :bn<cr>
map <leader>p :bp<cr>
map <leader>d :bd<cr>
-"" Set alt + j/k to switch lines of texts or simply move them
-":nnoremap <silent><A-k> :let save_a=@a<Cr><Up>"add"ap<Up>:let @a=save_a<Cr>
-":nnoremap <silent><A-j> :let save_a=@a<Cr>"add"ap:let @a=save_a<Cr>
+" tab navigation
+noremap <C-t>h :tabprevious<CR>
+noremap <C-t>l :tabnext<CR>
+noremap <C-t>k :tabfirst<CR>
+noremap <C-t>j :tablast<CR>
+noremap <C-t>n :tabnew<CR>
+noremap <C-t>e :tabedit<Space>
+noremap <C-t>c :tabclose<CR>
+noremap <C-t>m :tabm<Space>
" Swap two pieces of text, use x to cut in visual mode, then use Ctrl-x in
" visual mode to select text to swap with
@@ -79,21 +85,13 @@ nnoremap <leader>x :silent !chmod +x %<CR>
" Settings
"===============================================================================
-" enable syntax, plugins (for netrw) and indentation
-syntax enable
-
-"set shell=zsh
-set termguicolors
-set guicursor=
-let &t_SI = "\e[6 q"
-let &t_EI = "\e[2 q"
-
" Neovim requires xclip, check if normal vim has +clipboard by
" <:echo has('clipboard')> from within Vim (if the output is 1, good to
" go otherwise 0 then need a build that has it
" Next two commands make vim use X11 clipboard
set clipboard+=unnamedplus
let g:clipbrdDefaultReg = '+'
+
"let g:loaded_clipboard_provider = 1
" <:e %:h/filename> will create a new file named filename in the same
" directory as the currently open file, and write it.
@@ -102,7 +100,7 @@ set splitright " make vsplit put the new buffer on the right of the current buff
set splitbelow " make split put the new buffer below the current buffer
" :Bclose script (delete a buffer without closing the window) sourced as a
" plugin in ~/.config/nvim/plugin/bclose.vim | keymap: <leader>bd
-let bclose_multiple = 1
+"let bclose_multiple = 1
"set syntax
" Compute syntax highlighting from beginning of file. (By default, vim only
" looks 200 lines back, which can make it highlight code incorrectly in some
@@ -110,8 +108,10 @@ let bclose_multiple = 1
autocmd BufEnter * :syntax sync fromstart
" Don't syntax highlight markdown because it's often wrong
autocmd! FileType mkd setlocal syn=off
-"set ttyfast
-"set lazyredraw
+set ttyfast
+set lazyredraw
+" Set lazyredraw to false
+"let &lazyredraw = 0
set timeout timeoutlen=1000 ttimeoutlen=100 " fix slow O inserts
set scrolloff=8 sidescrolloff=8
set tabstop=4 softtabstop=4 shiftwidth=4 expandtab
@@ -129,7 +129,7 @@ set smartcase
set noswapfile
set nobackup
set incsearch
-set cursorline
+"set cursorline
set showmatch
set showcmd
set incsearch
@@ -149,6 +149,7 @@ set autoread " if a file is changed outside of vim, automatically reload it with
set diffopt=vertical " diffs are shown side-by-side not above/below
set signcolumn=no " always show the sign column
set textwidth=80
+set mouse=a
" FILE BROWSING:
let g:netrw_banner=0 " disable annoying banner
@@ -164,259 +165,27 @@ if executable("rg")
set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
-"-------------------------------------------------------------------------------
-
-
-"===============================================================================
-" Plugins
-"===============================================================================
-
-" Auto-Install vim-plug
-"if empty(glob('~/.vim/autoload/plug.vim'))
-" silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
-" \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
-" "autocmd VimEnter * PlugInstall
-" "autocmd VimEnter * PlugInstall | source $MYVIMRC
-"endif
-"
-"" :so % :PlugInstall
-"call plug#begin('~/.vim/autoload/plugged')
-""Plug 'glepnir/dashboard-nvim'
-"Plug 'christoomey/vim-tmux-navigator'
-"Plug 'preservim/vimux'
-"Plug 'myusuf3/numbers.vim'
-"Plug 'romainl/vim-cool'
-""Plug 'ervandew/supertab'
-""Plug 'neoclide/coc.nvim', {'branch': 'release'}
-"Plug 'sheerun/vim-polyglot'
-"Plug 'vim-airline/vim-airline'
-"Plug 'ryanoasis/vim-devicons'
-"Plug 'rbgrouleff/bclose.vim'
-""Plug 'ms-jpq/chadtree', {'branch': 'chad', 'do': 'python3 -m chadtree deps'}
-"Plug 'lambdalisue/fern.vim'
-"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
-"Plug 'junegunn/fzf.vim'
-"Plug 'airblade/vim-rooter'
-""Plug 'SirVer/ultisnips'
-""Plug 'honza/vim-snippets'
-"Plug 'airblade/vim-gitgutter'
-"Plug 'tpope/vim-eunuch'
-"Plug 'tpope/vim-fugitive'
-"Plug 'tpope/vim-surround'
-"Plug 'tpope/vim-obsession'
-"Plug 'tpope/vim-unimpaired'
-"Plug 'scrooloose/syntastic'
-"Plug 'w0rp/ale'
-"Plug 'davidhalter/jedi-vim'
-""Plug 'valloric/youcompleteme' " vim needs to be compiled with python/ compiled with install.py in plugin directory
-"Plug 'Lenovsky/nuake'
-"Plug 'voldikss/vim-floaterm'
-"Plug 'gruvbox-community/gruvbox'
-"Plug 'srcery-colors/srcery-vim'
-"Plug 'tomasr/molokai'
-"Plug 'ayu-theme/ayu-vim'
-"Plug 'sjl/badwolf'
-"Plug 'joshdick/onedark.vim'
-"call plug#end()
-
-"source $HOME/.vim/plug-config/coc.vim
-
-"-------------------------------------------------------------------------------
-
"===============================================================================
-" Plugin Settings
+" Colorscheme
"===============================================================================
-"" Fugitive statusline
-""---------------------------------------
-""set statusline=%{fugitive#statusline()}%F%m%r%h%w\ (%{&ff}){%Y}\ [%l,%v][%p%%]
-""-------------------------------------------------------------------------------
-""" Show the buffer number in the status line.
-""set statusline=%02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
-""set statusline=%{fugitive#statusline()}02n:%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
-
-""-------------------------------------------------------------------------------
-"
-"" Airline
-""---------------------------------------
-"let g:airline#extensions#tabline#enabled = 1
-"let g:airline#extensions#tabline#show_buffers = 1
-"let g:airline_powerline_fonts = 1
-"let g:airline#extensions#tabline#buffer_nr_show = 1
-"let g:airline_theme='onedark'
-"
-""-------------------------------------------------------------------------------
-"
-"" Float Term
-""---------------------------------------
-"" Configuration example
-"let g:floaterm_keymap_new = '<Leader>t'
-"let g:floaterm_keymap_prev = '<Leader>tn'
-"let g:floaterm_keymap_next = '<Leader>tp'
-"let g:floaterm_keymap_toggle = '<Leader>tt'
-"
-""-------------------------------------------------------------------------------
-"
-"" Nuake
-""---------------------------------------
-"" Toggle Nuake terminal panel
-"nnoremap <A-t> :Nuake<CR>
-"inoremap <A-t> <C-\><C-n>:Nuake<CR>
-"tnoremap <A-t> <C-\><C-n>:Nuake<CR>
-"let g:nuake_per_tab = 1 " Enable the Nuake instance per tab page. (default 1)
-"let g:close_if_last_standing = 1 " Close the editor if the Nuake window is the last one. (default 1)
-"let g:nuake_position = 'right'
-""let g:nuake_size = 0.2
-
-""-------------------------------------------------------------------------------
-"
-"" Vimux
-""---------------------------------------
-"" Prompt for a command to run
-"map <Leader>vp :VimuxPromptCommand<CR>
-"" Run last command executed by VimuxRunCommand
-"map <Leader>vl :VimuxRunLastCommand<CR>
-"" Inspect runner pane
-"map <Leader>vi :VimuxInspectRunner<CR>
-"" Zoom the tmux runner pane
-"map<leader>vz :VimuxZoomRunner<CR>
-
-""-------------------------------------------------------------------------------
-"
-"" Snippets
-""---------------------------------------
-"" Snippets — code snippets allow you to quickly write some boilerplate code
-"" that is often repetitive. To add code snippets support, you will have to add
-"" UltiSnips.
-"let g:UltiSnipsExpandTrigger = "<c-tab>"
-""let g:UltiSnipsJumpForwardTrigger = "<tab>"
-""let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
-
-""-------------------------------------------------------------------------------
-"
-"" Youcompleteme
-""---------------------------------------
-""let g:ycm_global_ycm_extra_conf = '~/.config/nvim/autoload/plugged/youcompleteme/.ycm_extra_conf.py'
-"" ---> compatibility with another plugin (ultisnips) <---
-""let g:ycm_key_list_select_completion = [ '<C-n>', '<Down>' ]
-""let g:ycm_key_list_previous_completion = [ '<C-p>', '<Up>' ]
-""let g:SuperTabDefaultCompletionType = '<C-n>'
-"" ---> disable preview window <---
-""set completeopt-=preview
-"" ---> navigating to the definition of a a symbol <---
-""map <leader>g :YcmCompleter GoToDefinitionElseDeclaration<CR>
-
-""-------------------------------------------------------------------------------
-"
-"
-""===============================================================================
-"" File Manager & FZF
-""===============================================================================
-"
-"" CHADTree Filemanager/project drawer (NerdTree killer)
-""---------------------------------------
-""" to toggle CHADTree run command :CHADopen or use hotkey <leader>v :
-""nnoremap <leader>f <cmd>CHADopen<cr>
-"""nnoremap <leader>v <cmd>CHADopen<cr> " Default Behaviour
-""nnoremap <A-f> <cmd>CHADopen<cr>
-""" :CHADhelp to view documentation
-""" Add a hotkey to clear quickfix list:
-"""nnoremap <leader>qk <cmd>call setqflist([])<cr>
-""let g:chadtree_settings = { 'view.width': 25 }
-
-""-------------------------------------------------------------------------------
-"
-"" FZF fuzzy finder
-""---------------------------------------
-"" 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'
-"map <leader>z :FZF<CR>
-"map <leader>a :Files<CR>
-"map <leader>l :Lines<CR>
-"map <leader>L :BLines<CR>
-"map <leader>B :Buffers<CR>
-"map <leader>h :History:<CR>
-"nnoremap <leader>g :Rg<CR>
-""nnoremap <leader>t :Tags<CR>
-"nnoremap <leader>m :Marks<CR>
-"" This is the default extra key bindings
-"let g:fzf_action = {
-" \ 'ctrl-t': 'tab split',
-" \ 'ctrl-x': 'split',
-" \ 'ctrl-y': 'vsplit' }
-"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 --info=inline'
-"let $FZF_DEFAULT_COMMAND="rg --files --hidden"
-"" 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', '--info=inline']}), <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 '.shellescape(<q-args>), 1,
-" \ fzf#vim#with_preview(), <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)
-"command! -bang FM call fzf#run(fzf#wrap({'source': 'cat ~/.fzf-marks | sed "s/.*: \(.*\)$/\1/" | sed "s#~#${HOME}#"', 'sink': 'lcd'}, <bang>0))
-"
-"-------------------------------------------------------------------------------
-
+" enable syntax, plugins (for netrw) and indentation
+syntax enable
-"===============================================================================
-" Colorscheme
-"===============================================================================
+"set shell=zsh
+set termguicolors
+set guicursor=
+let &t_SI = "\e[6 q"
+let &t_EI = "\e[2 q"
-"colorscheme gruvbox
-"colorscheme srcery
-"colorscheme molokai
-"colorscheme ayu
-"let ayucolor="light" " for light version of theme
-"let ayucolor="mirage" " for mirage version of theme
-"let ayucolor="dark" " for dark version of theme
-"colorscheme badwolf
-"let g:badwolf_darkgutter = 0 " Make the gutters darker than the background. Default 0.
-"let g:badwolf_tabline = 1 " 1 is default, 0 is lighter and 2 or 3 is darker a tabline
-
-" Try to use a colorscheme plugin
-" but fallback to a default one
-colorscheme desert
+"colorscheme desert
+"colorscheme city-lights
+set background=dark
highlight Normal guibg=NONE ctermbg=NONE
highlight EndOfBuffer ctermfg=NONE ctermbg=NONE
-"set background=dark
-"
+
+
"-------------------------------------------------------------------------------
@@ -470,42 +239,41 @@ map <leader>r :call RenameFile()<cr>
"-------------------------------------------------------------------------------
"
-" Function to update tmux status
-function! UpdateTmuxStatus()
- if &filetype == "man"
+" Function to update tmux status and .vi-mode file
+"---------------------------------------
+function! UpdateTmuxStatus() abort
+ " Check if the current buffer has a man filetype
+ if &filetype ==# 'man'
return
endif
+ " Determine the mode name based on the mode value
let mode = mode()
let mode_name = ''
if mode ==# 'n'
- let mode_name = "-- NORMAL --"
+ let mode_name = '-- NORMAL --'
elseif mode ==# 'i' || mode ==# 'ic'
- let mode_name = "-- INSERT --"
+ let mode_name = '-- INSERT --'
else
- let mode_name = "-- NORMAL --"
+ let mode_name = '-- NORMAL --'
endif
- let file = $HOME . "/.vi-mode"
- call writefile([mode_name], file)
+ " Write the mode name to the file
+ call writefile([mode_name], expand('$HOME') . '/.vi-mode')
- if exists('*nvim_running')
- let VI_MODE = "" " Clear VI_MODE to show vim mode
- silent execute "!tmux refresh-client -S"
- endif
- silent execute "!tmux refresh-client -S"
+endfunction
+
+" Function to refresh tmux status
+function! s:UpdateTmux() abort
+ call system('tmux refresh-client -S')
endfunction
" Set up autocommands for tmux status update
if !empty($TMUX) && system('command -v tmux >/dev/null 2>&1') == 0
- augroup TmuxStatus
- autocmd!
- autocmd InsertLeave,InsertEnter * call UpdateTmuxStatus()
- autocmd VimEnter * call UpdateTmuxStatus()
- autocmd BufEnter * call UpdateTmuxStatus()
- autocmd ModeChanged * call UpdateTmuxStatus()
- autocmd WinEnter,WinLeave * call UpdateTmuxStatus()
- augroup END
+augroup TmuxStatus
+ autocmd!
+ autocmd ModeChanged * call UpdateTmuxStatus() | call s:UpdateTmux()
+augroup END
endif
"-------------------------------------------------------------------------------
@@ -515,6 +283,8 @@ endif
" Statusline Configuration
"===============================================================================
+" Autoload statusline
+"---------------------------------------
" Load statusline script
if filereadable(expand("~/.vim/autoload/statusline.vim"))
source ~/.vim/autoload/statusline.vim
@@ -523,4 +293,4 @@ endif
" Call the statusline activation function
call autoload#statusline#ActivateStatusline()
-
+"-------------------------------------------------------------------------------