nvim-old
This commit is contained in:
parent
dbba54cfd8
commit
6380f390ea
|
@ -0,0 +1,10 @@
|
|||
how to run tests:
|
||||
first make sure lua, lua rocks, and `luarocks install busted` are all set up.
|
||||
|
||||
then, run:
|
||||
```
|
||||
busted -p test_ lua/tests/
|
||||
```
|
||||
- `-p` means the test files don't need some weird naming convention. I believe it also implies that all my files beging with `test_`
|
||||
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
" REMAPS
|
||||
nnoremap <leader>gf :Telescope git_files<cr>
|
||||
|
||||
"Harpoon
|
||||
nnoremap <leader>pf :lua require("harpoon.mark").add_file()<cr>
|
||||
nnoremap <leader>pf :lua require("harpoon.ui").toggle_quick_menu()
|
||||
nnoremap <leader>pf :lua require("harpoon.ui").toggle_quick_menu()
|
||||
|
||||
"set timeout timeoutlen=1000 ttimeoutlen=100
|
||||
"inoremap <C-c> <Esc>:w<CR>
|
||||
"
|
||||
|
||||
"netrw to automatically change working directory
|
||||
au FileType netrw nmap <buffer> <leader>% mt:!tmux split-window -h;tmux select-layout even-horizontal<CR>
|
||||
au FileType netrw nmap <buffer> <leader>z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"open current NETRW directory in a new tab
|
||||
nnoremap <leader>z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"open current NETRW directory in a new tab
|
||||
nnoremap <leader>% mt:!tmux split-window -h;tmux select-layout even-horizontal<CR>
|
||||
|
||||
function! OpenInTmuxPane()
|
||||
" Get the current directory from the netrw buffer
|
||||
let l:current_dir = b:netrw_curdir
|
||||
|
||||
" Get the name of the file under the cursor
|
||||
let l:filename = expand('<cfile>')
|
||||
|
||||
" Combine the directory and filename to get the full path
|
||||
let l:filepath = l:current_dir . '/' . l:filename
|
||||
|
||||
" Prepare the tmux command
|
||||
let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'"
|
||||
|
||||
" Call the command
|
||||
call system(l:tmux_command)
|
||||
endfunction
|
||||
|
||||
nnoremap <leader>4 :call OpenInTmuxPane()<CR>
|
||||
|
||||
"netrw copy a file
|
||||
au FileType netrw nmap <buffer> <leader>yp mt:!cp -r <C-R><C-F> ./<C-R><C-F>
|
||||
"netrw delete under cursor
|
||||
au FileType netrw nmap <buffer> <leader>x mt:!rm -rf <C-R><C-F><CR><CR>
|
||||
"netrw mkdir command
|
||||
au FileType netrw nmap <buffer> <leader>mkdir mt:!mkdir -p
|
||||
|
||||
"let ctrlp search for hidden files and directories
|
||||
let g:ctrlp_show_hidden = 1
|
||||
|
||||
" Neovim :Terminal
|
||||
tmap <Esc> <C-\><C-n>
|
||||
|
||||
" indentLine
|
||||
let g:indentLine_char = '▏'
|
||||
let g:indentLine_defaultGroup = 'NonText'
|
||||
" Disable indentLine from concealing json and markdown syntax (e.g. ```)
|
||||
"let g:vim_json_syntax_conceal = 0
|
||||
"let g:vim_markdown_conceal = 0
|
||||
"let g:vim_markdown_conceal_code_blocks = 0
|
||||
|
||||
" TagBar
|
||||
let g:tagbar_width = 40
|
||||
|
||||
" Limelight
|
||||
let g:limelight_conceal_ctermfg = 'gray'
|
||||
let g:limelight_conceal_guifg = 'gray'
|
||||
nmap <Leader>l :Limelight!!<CR>
|
||||
xmap <Leader>l :Limelight!!<CR>
|
||||
autocmd! User GoyoEnter Limelight
|
||||
autocmd! User GoyoLeave Limelight!
|
||||
" Startify
|
||||
"let g:startify_fortune_use_unicode = 1
|
||||
|
||||
"" Startify + NERDTree on start when no file is specified
|
||||
"let &tags = expand("%:p")
|
||||
|
||||
"COC VIM START
|
||||
|
||||
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
" delays and poor user experience.
|
||||
set updatetime=300
|
||||
|
||||
" Don't pass messages to |ins-completion-menu|.
|
||||
set shortmess+=c
|
||||
|
||||
" Always show the signcolumn, otherwise it would shift the text each time
|
||||
" diagnostics appear/become resolved.
|
||||
if has("nvim-0.5.0") || has("patch-8.1.1564")
|
||||
"" Recently vim can merge signcolumn and number column into one
|
||||
set signcolumn=number
|
||||
else
|
||||
set signcolumn=yes
|
||||
endif
|
||||
|
||||
" FixCursorHold for better performance
|
||||
let g:cursorhold_updatetime = 100
|
||||
|
||||
" context.vim
|
||||
let g:context_nvim_no_redraw =1
|
||||
|
||||
""" Filetype-Specific Configurations
|
||||
|
||||
" HTML, XML, Jinja
|
||||
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType xml setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType htmldjango inoremap {{ {{ }}<left><left><left>
|
||||
autocmd FileType htmldjango inoremap {% {% %}<left><left><left>
|
||||
autocmd FileType htmldjango inoremap {# {# #}<left><left><left>
|
||||
|
||||
" Markdown and Journal
|
||||
autocmd FileType markdown setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType journal setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
|
||||
"scroll sync lock
|
||||
nnoremap <leader><leader>sl :set scb!<CR>
|
||||
|
||||
nmap <silent> <leader>no :set hlsearch!<CR>
|
||||
|
||||
let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
"Go to last position in file
|
||||
autocmd BufWinLeave * silent! mkview
|
||||
autocmd BufWinEnter * silent! loadview
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
"system clipboard on wsl2
|
||||
if system('uname -r') =~ "microsoft"
|
||||
augroup Yank
|
||||
autocmd!
|
||||
autocmd TextYankPost * :call system('/mnt/c/windows/system32/clip.exe ',@")
|
||||
augroup END
|
||||
endif
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
"function! TmuxSplitEvenHorizontal()
|
||||
"let filepath = expand('%:p')
|
||||
"if !empty(filepath)
|
||||
"let tmux_command = "tmux split-window -h -c '#{pane_current_path}' 'nvim ".filepath."' && tmux select-layout even-horizontal"
|
||||
"call system(tmux_command)
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
function! TmuxSplitEvenHorizontal()
|
||||
let filepath = expand('%:p')
|
||||
if !empty(filepath)
|
||||
let tmux_command = "tmux split-window -h -c '".expand('%:p:h')."' && tmux send-keys -t '.tmux.active-pane' 'nvim ".shellescape(filepath)."' Enter && tmux select-layout even-horizontal"
|
||||
call system(tmux_command)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <leader>th :call TmuxSplitEvenHorizontal()<CR>
|
||||
|
||||
function! ToggleRelAbsNumbers()
|
||||
set relativenumber
|
||||
set number
|
||||
else
|
||||
set norelativenumber
|
||||
set nonumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
" Functions and autocmds to run whenever changing colorschemes
|
||||
function! TransparentBackground()
|
||||
highlight Normal guibg=NONE ctermbg=NONE
|
||||
highlight LineNr guibg=NONE ctermbg=NONE
|
||||
set fillchars+=vert:\│
|
||||
highlight VertSplit gui=NONE guibg=NONE guifg=#444444 cterm=NONE ctermbg=NONE ctermfg=gray
|
||||
endfunction
|
||||
|
||||
autocmd ColorScheme * call TransparentBackground() " uncomment if you are using a translucent terminal and you want nvim to use that
|
||||
|
||||
|
||||
function! ToggleLineNumbers()
|
||||
if &relativenumber
|
||||
set norelativenumber
|
||||
set number
|
||||
else
|
||||
set relativenumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <leader><leader>n :call ToggleLineNumbers()<CR>
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
" VIM RECORDING
|
||||
"q<letter> to start recording
|
||||
"q to stop recording
|
||||
"@<letter> to play back recording
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
"save with ctrl s
|
||||
nnoremap <C-s> <C-c>:w<CR>
|
||||
inoremap <C-c> <Esc><right>
|
||||
inoremap <Esc> <Esc><right>
|
|
@ -0,0 +1,23 @@
|
|||
|
||||
|
||||
"give syntax highlighting to sh files with zsh syntax highlighting
|
||||
au BufRead,BufNewFile *.sh setfiletype zsh
|
||||
|
||||
" current directory to match netrw browsing
|
||||
let g:netrw_keepdir= 0
|
||||
|
||||
|
||||
"ends up going to the same directory but doesn't open a file
|
||||
"function! OpenInTmuxPane()
|
||||
"" Get the full path of the current file
|
||||
""let l:filepath = netrw#LocalBrowseCheck("")
|
||||
""echo l:filepath
|
||||
"let l:filepath = expand('%:p')
|
||||
|
||||
"" Prepare the tmux command
|
||||
"let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'"
|
||||
|
||||
"" Call the command
|
||||
"call system(l:tmux_command)
|
||||
"endfunction
|
||||
|
|
@ -0,0 +1,254 @@
|
|||
" EasyAlign
|
||||
xmap ga <Plug>(EasyAlign)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
|
||||
|
||||
|
||||
"lua require ('init')
|
||||
"let g:coq_settings = { 'auto_start': v:true }
|
||||
"
|
||||
"" vim-pydocstring
|
||||
let g:pydocstring_doq_path = '~/.config/nvim/env/bin/doq'
|
||||
|
||||
|
||||
"return to previous place in buffer
|
||||
|
||||
""" Main Configurations
|
||||
"filetype plugin indent on
|
||||
|
||||
"nmap M <Plug>MoveMotionEndOfLinePlug
|
||||
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
" other plugin before putting this into your config.
|
||||
"inoremap <silent><expr> <TAB>
|
||||
"\ pumvisible() ? "\<C-n>" :
|
||||
"\ <SID>check_back_space() ? "\<TAB>" :
|
||||
"\ coc#refresh()
|
||||
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
"function! s:check_back_space() abort
|
||||
"let col = col('.') - 1
|
||||
"return !col || getline('.')[col - 1] =~# '\s'
|
||||
"endfunction
|
||||
|
||||
" Use <c-space> to trigger completion.
|
||||
"if has('nvim')
|
||||
""inoremap <silent><expr> <c-space> coc#refresh()
|
||||
"else
|
||||
""inoremap <silent><expr> <c-@> coc#refresh()
|
||||
"endif
|
||||
|
||||
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
||||
" format on enter, <cr> could be remapped by other vim plugin
|
||||
"inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
""\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" GoTo code navigation.
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gt <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window.
|
||||
"nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
"function! s:show_documentation()
|
||||
"if (index(['vim','help'], &filetype) >= 0)
|
||||
"execute 'h '.expand('<cword>')
|
||||
"elseif (coc#rpc#ready())
|
||||
"call CocActionAsync('doHover')
|
||||
"else
|
||||
"execute '!' . &keywordprg . " " . expand('<cword>')
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
" Highlight the symbol and its references when holding the cursor.
|
||||
"autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Symbol renaming.
|
||||
"nnoremap <leader>9 <Plug>(coc-rename)
|
||||
"nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Formatting selected code.
|
||||
"xmap <leader>= <Plug>(coc-format-selected)
|
||||
"nmap <leader>= <Plug>(coc-format-selected)
|
||||
|
||||
"augroup mygroup
|
||||
"autocmd!
|
||||
""" Setup formatexpr specified filetype(s).
|
||||
"autocmd FileType typescript,json,python,yaml setl formatexpr=CocAction('formatSelected')
|
||||
""" Update signature help on jump placeholder.
|
||||
"autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
"augroup end
|
||||
|
||||
"let g:python3_host_prog = "/usr/bin/python3.8"
|
||||
" coc.vim END
|
||||
|
||||
" signify
|
||||
"let g:signify_sign_add = '│'
|
||||
"let g:signify_sign_delete = '│'
|
||||
"let g:signify_sign_change = '│'
|
||||
"hi DiffDelete guifg=#ff5555 guibg=none
|
||||
|
||||
|
||||
""" Custom Functions
|
||||
|
||||
" Trim Whitespaces
|
||||
"function! TrimWhitespace()
|
||||
"let l:save = winsaveview()
|
||||
"%s/\\\@<!\s\+$//e
|
||||
"call winrestview(l:save)
|
||||
"endfunction
|
||||
|
||||
""" CUSTOM MAPPINGS
|
||||
|
||||
"open up a terminal
|
||||
nmap <leader><C-t> <c-W>s<C-w>j:terminal<CR>:set nonumber<CR><S-a>
|
||||
nmap <C-t> <C-w>v<C-w>l:terminal<CR>:set nonumber<CR><S-a>
|
||||
|
||||
" NerdTree
|
||||
"nmap <leader>q :NERDTreeToggle<CR>
|
||||
"nnoremap <leader>e :NERDTreeFocus<CR>
|
||||
"nnoremap <C-f> :NERDTreeFind<CR> """open NerdTree current directory"""
|
||||
"nmap \\ <leader>q
|
||||
"
|
||||
"CHADtree
|
||||
"let &tags = expand("%:p")
|
||||
"nnoremap <leader>e :CHADopen<CR>
|
||||
"nnoremap <leader>3 :CHADopen --always-focus<CR>
|
||||
|
||||
"nnoremap <leader>e :Vexplore<CR><C-w>r
|
||||
"nnoremap <leader>E :Ex<CR>
|
||||
|
||||
"Tagbar
|
||||
"nmap <leader>w :TagbarToggle<CR>
|
||||
"nmap \| <leader>w
|
||||
|
||||
"Source vim
|
||||
nmap <leader>R :so ~/.config/nvim/init.vim<CR>
|
||||
|
||||
|
||||
"nmap <leader>t :call TrimWhitespace()<CR>
|
||||
"nmap <leader>y <C-w>v<C-w>l:HackerNews best<CR>J
|
||||
"nmap <leader>p <Plug>(pydocstring)
|
||||
|
||||
"easy align
|
||||
xmap <leader>a gaip*
|
||||
nmap <leader>a gaip*
|
||||
"nmap <leader>s :Rg<CR>
|
||||
"
|
||||
""quick grep search
|
||||
"all system files -- not useful
|
||||
"nmap <leader>d :Files<CR>
|
||||
"nnoremap <silent> <Leader>h: :History:<CR>
|
||||
"nnoremap <silent> <Leader>h/ :History/<CR>
|
||||
""latest files -- very useful!
|
||||
"nnoremap <silent> <Leader>hh :History<CR>
|
||||
""find file in line
|
||||
"nmap <leader>z :BLines<CR>
|
||||
"nmap <leader>H :RainbowParentheses!!<CR>
|
||||
"nnoremap """ :reg<CR>
|
||||
"
|
||||
|
||||
|
||||
"nmap <leader>g :Goyo<CR>
|
||||
"nmap <leader>j :set filetype=journal<CR>
|
||||
"nmap <leader>l :Limelight!!<CR>
|
||||
"xmap <leader>l :Limelight!!<CR>
|
||||
"
|
||||
"I actually don't like what this does. It makes the python indent all weird.
|
||||
"Figure out what plugin would cause indent to be like this, then delete it.
|
||||
"I still have an annoying indentation error when I'm typing as well.
|
||||
"autocmd FileType python nmap <leader>x :0,$!~/.config/nvim/env/bin/python -m yapf<CR>
|
||||
|
||||
|
||||
"nmap <Tab> :tabn<CR>
|
||||
"nmap <S-Tset -g status-left "#{pane_current_path}"ab> :tabp<CR>
|
||||
|
||||
" view current buffers and type the number you want to go to.
|
||||
":bd to delete a single buffer
|
||||
nnoremap <F5> :buffers<CR>:buffer<Space>
|
||||
|
||||
"go back to file tree
|
||||
"nnoremap <C-e> :Ex
|
||||
|
||||
"splits
|
||||
nnoremap <leader><v> :vsplit<CR>
|
||||
"nnoremap <leader><C-h> <C-w><s>
|
||||
|
||||
"Navigate split buffers
|
||||
"Normal Mode
|
||||
nnoremap <C-j> <C-w><C-j>
|
||||
nnoremap <C-k> <C-W><C-k>
|
||||
nnoremap <C-l> <C-W><C-l>
|
||||
nnoremap <C-h> <C-W><C-h>
|
||||
"Terminal mode
|
||||
tnoremap <C-j> <C-\><C-n><C-W><C-J>
|
||||
tnoremap <C-k> <C-\><C-n><C-W><C-K>
|
||||
tnoremap <C-l> <C-\><C-n><C-W><C-L>
|
||||
tnoremap <C-h> <C-\><C-n><C-W><C-H>
|
||||
|
||||
|
||||
"add current cursor position to jumplist
|
||||
nnoremap <Leader>m :autocmd CursorHold * normal! m'<CR>
|
||||
|
||||
|
||||
""easymotion mappings
|
||||
|
||||
"nnoremap <Leader>f <Plug>(easymotion-prefix)f
|
||||
"nnoremap <Leader>s <Plug>(easymotion-s2)
|
||||
"nnoremap <Leader>f <Plug>(easymotion-prefix)s
|
||||
"nnoremap <c-_> <Plug>(easymotion-sn)
|
||||
"nnoremap <Leader>/ <Plug>(easymotion-sn)
|
||||
"nnoremap <Leader>F <Plug>(easymotion-prefix)F
|
||||
"nnoremap <Leader>s <Plug>(easymotion-prefix)s
|
||||
|
||||
|
||||
"map <C-;> <Plug>(easymotion-next)
|
||||
"map <C-,> <Plug>(easymotion-prev)" Terminal mode:
|
||||
"nmap <leader>f <Plug>(easymotion-overwin-f)
|
||||
"nmap <leader>cf c<Plug>(easymotion-overwin-f)
|
||||
"nmap s <Plug>(easymotion-overwin-f2)
|
||||
" Turn on case-insensitive feature
|
||||
let g:EasyMotion_smartcase = 1
|
||||
|
||||
"fuzzy finder
|
||||
"I have to remap ctrlp's default in order to make my custom command to work
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
"open up all files including dotfiles
|
||||
nnoremap <leader>p :CtrlP /home/ldraney<CR>
|
||||
set wildignore+=*/.vim/*
|
||||
"
|
||||
|
||||
"Rename tmux window tab after current file with path
|
||||
"autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window " . expand("%:t"))
|
||||
|
||||
|
||||
"tmap <C-w> <Esc><C-w>
|
||||
"tmap <C-d> <Esc>:q<CR>
|
||||
|
||||
"delete
|
||||
"I don't know what this does...
|
||||
"autocmd BufWinEnter,WinEnter term://* startinsert
|
||||
"autocmd BufLeave term://* stopinsert
|
||||
|
||||
|
||||
":!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"OVERCOMING ANNOYING LITTLE VIM THINGS
|
||||
"nnoremap <CR> <CR><left>
|
||||
"inoremap <CR> <CR><left>
|
||||
"nnoremap o o<left>
|
||||
|
||||
"highlight search settings
|
||||
"highlight link Searchlight Incsearch
|
||||
"hi Search guibg=white guifg=green
|
||||
"hi Search cterm=NONE ctermfg=grey ctermbg=blue
|
||||
""" PLUGIN CONFIGURATIONS
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
" Main Coloring Configurations
|
||||
syntax on
|
||||
color gruvbox
|
||||
" Enable True Color Support (ensure you're using a 256-color enabled $TERM, e.g. xterm-256color)
|
||||
set termguicolors
|
||||
"
|
||||
"CURSOR SETTINGS
|
||||
"cursor settings MUST COME AFTER set TERMGUICOLORS
|
||||
"https://github.com/neovim/neovim/wiki/FAQ#nvim-shows-weird-symbols-2-q-when-changing-modes
|
||||
"highlight Cursor guifg=blue guibg=blue
|
||||
"set guicursor=i:block-Cursor-blinkon1
|
||||
"set guicursor=i:hor
|
||||
highlight Cursor guifg=blue guibg=blue
|
||||
autocmd InsertEnter * set cul
|
||||
autocmd InsertLeave * set nocul
|
||||
|
||||
set syn=sh
|
||||
nnoremap <leader>s :call ToggleRelAbsNumbers()<CR>
|
||||
|
||||
"use alt-/ to search within a highlighted visual field
|
||||
vnoremap <M-/> <Esc>/\%V
|
||||
"
|
||||
|
||||
" Enable automatic formatting of Terraform files on save
|
||||
let g:terraform_fmt_on_save = 1
|
||||
|
||||
" SETS
|
||||
"set startdir=$NVIM_PWD
|
||||
|
||||
set writebackup
|
||||
"set patchmode=.orig
|
||||
set backupcopy=yes
|
||||
set backupdir=~/Backups
|
||||
|
||||
"set number
|
||||
"set relativenumber
|
||||
|
||||
"set statusline=%!MyStatusLine()
|
||||
"function! MyStatusLine()
|
||||
set statusline+=%F
|
||||
let g:netrw_keepdir= 0
|
||||
|
||||
" this should open help in a vertical split
|
||||
set splitright
|
||||
|
||||
set formatoptions-=cro
|
||||
set nopaste
|
||||
"set tabline
|
||||
set conceallevel=0
|
||||
set autochdir
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set tabstop=4 softtabstop=4 shiftwidth=2
|
||||
set mouse=a
|
||||
set indentexpr=''
|
||||
"set expandtab
|
||||
"set autoindent
|
||||
"set smarttab
|
||||
"set incsearch ignorecase smartcase hlsearch
|
||||
set nohlsearch
|
||||
"set hlsearch!
|
||||
set wildmode=longest,list,full wildmenu
|
||||
set ruler laststatus=2 showcmd showmode
|
||||
set list listchars=trail:»,tab:»-
|
||||
set fillchars+=vert:\
|
||||
set wrap breakindent
|
||||
set encoding=utf-8
|
||||
set textwidth=0
|
||||
set nohidden
|
||||
set title
|
||||
set undodir=~/.vim/undodir "I need to set up this directory
|
||||
set undofile
|
||||
set incsearch
|
||||
set backspace
|
||||
set autoread
|
||||
set scrolloff=10
|
||||
set colorcolumn=80
|
||||
set clipboard=unnamed,unnamedplus
|
||||
|
||||
set nocindent
|
||||
set showbreak=>>
|
||||
"set nosmartindent
|
||||
"set noautoindent
|
||||
"set indentexpr=
|
||||
"filetype indent off
|
||||
"filetype plugin indent off
|
||||
set relativenumber
|
|
@ -0,0 +1,695 @@
|
|||
|
||||
"use alt-/ to search within a highlighted visual field
|
||||
vnoremap <M-/> <Esc>/\%V
|
||||
"
|
||||
"Go to last position in file (also loads folding)
|
||||
autocmd BufWinLeave * silent! mkview
|
||||
autocmd BufWinEnter * silent! loadview
|
||||
|
||||
" current directory to match netrw browsing
|
||||
let g:netrw_keepdir= 0
|
||||
|
||||
"give syntax highlighting to sh files with zsh syntax highlighting
|
||||
au BufRead,BufNewFile *.sh setfiletype zsh
|
||||
set syn=sh
|
||||
|
||||
call plug#begin()
|
||||
|
||||
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
|
||||
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
|
||||
|
||||
" relative and absolute line numbers
|
||||
"Plug 'sitiom/nvim-numbertoggle'
|
||||
|
||||
"format json files
|
||||
Plug 'XadillaX/json-formatter.vim'
|
||||
"must also run:
|
||||
"npm install -g jjson
|
||||
"usage:
|
||||
":JSONFormatter"
|
||||
|
||||
Plug 'github/copilot.vim'
|
||||
"must also run:
|
||||
":Copilot setup
|
||||
"# Go to my Microsoft Edge bookmark named "Copilot Login"
|
||||
":Copilot enable
|
||||
|
||||
"format terraform file with a :TerraformFmt ex command
|
||||
"Also include TerraformSyntax highlighting
|
||||
Plug 'hashivim/vim-terraform'
|
||||
|
||||
"bash script syntax highlighting
|
||||
"Plug 'godlygeek/tabular'
|
||||
"Plug 'arzg/vim-sh'
|
||||
|
||||
" Telescope stuff
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.6' }
|
||||
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
|
||||
Plug 'ThePrimeagen/harpoon'
|
||||
"Start using vim with googgle docs :)))
|
||||
"Plug 'aadv1k/gdoc.vim', {'do': './install.py'}
|
||||
|
||||
"LSP stuff
|
||||
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
"Plug 'neovim/nvim-lspconfig'
|
||||
|
||||
" AUTOCOMPLETE STUFF?
|
||||
"Plug 'hrsh7th/nvim-cmp'
|
||||
"Plug 'williamboman/nvim-lsp-installer'
|
||||
"Plug 'tami5/lspsaga.nvim'
|
||||
"Plug 'simrat39/symbols-outline.nvim'
|
||||
"Plug 'hrsh7th/nvim-cmp'
|
||||
"Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
"Plug 'saadparwaiz1/cmp_luasnip'
|
||||
"Plug 'L3MON4D3/LuaSnip'
|
||||
"Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
|
||||
"Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
|
||||
"Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'}
|
||||
"Plug 'heavenshell/vim-pydocstring', { 'do': 'make install' }
|
||||
"
|
||||
"Debugger
|
||||
"Plug 'puremourning/vimspector'
|
||||
|
||||
" AESTHETICS
|
||||
Plug 'gruvbox-community/gruvbox'
|
||||
|
||||
"highlighting plugins that may be useful when I'm a senior dev
|
||||
Plug 'junegunn/goyo.vim'
|
||||
Plug 'junegunn/limelight.vim'
|
||||
Plug 'junegunn/rainbow_parentheses.vim'
|
||||
|
||||
" FILE FORMATTING AND VISUAL HELPS
|
||||
|
||||
"smooth scrolling
|
||||
Plug 'psliwka/vim-smoothie'
|
||||
|
||||
"search blink
|
||||
Plug 'ivyl/vim-bling'
|
||||
|
||||
Plug 'antoinemadec/FixCursorHold.nvim'
|
||||
"
|
||||
"Super handy. Shows the current function or class when scrolling down
|
||||
Plug 'wellle/context.vim'
|
||||
|
||||
"useful for aligning dictionaries or other declarations
|
||||
"Plug 'junegunn/vim-easy-align'
|
||||
|
||||
"Plug 'lukas-reineke/indent-blankline.nvim'
|
||||
Plug 'lukas-reineke/indent-blankline.nvim', { 'tag': 'v3.3.10' }
|
||||
|
||||
" Automatic numbering and bullet points for new lines
|
||||
"Plug 'dkarter/bullets.vim'
|
||||
|
||||
" FUNCTIONALITIES
|
||||
Plug 'tpope/vim-repeat'
|
||||
"
|
||||
Plug 'ctrlpvim/ctrlp.vim'
|
||||
Plug 'preservim/nerdcommenter'
|
||||
Plug 'svermeulen/vim-easyclip' "Fixes the clipboard functionality
|
||||
|
||||
"Useful vim surround Keys:
|
||||
"1. cs"' to change the outer characters of current sentence
|
||||
"2. ds" to delete outer characters entirely
|
||||
"3. ysiw" to "surround current" word with "
|
||||
"4. yssb or yss( to wrap entire line with parenthesis
|
||||
"5. S" in visual mode will surround with quotes
|
||||
Plug 'tpope/vim-surround'
|
||||
|
||||
"shows an outline of imports, functions, and classes by scope
|
||||
Plug 'majutsushi/tagbar'
|
||||
|
||||
" git assistant
|
||||
Plug 'tpope/vim-fugitive'
|
||||
|
||||
"Plug 'ryanoasis/vim-devicons'
|
||||
"Plug 'kyazdani42/nvim-web-devicons'
|
||||
|
||||
"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
|
||||
Plug 'kshenoy/vim-signature'
|
||||
|
||||
call plug#end()
|
||||
|
||||
let g:NERDSpaceDelims = 1
|
||||
|
||||
" Enable automatic formatting of Terraform files on save
|
||||
let g:terraform_fmt_on_save = 1
|
||||
|
||||
"system clipboard on wsl2
|
||||
if system('uname -r') =~ "microsoft"
|
||||
augroup Yank
|
||||
autocmd!
|
||||
autocmd TextYankPost * :call system('/mnt/c/windows/system32/clip.exe ',@")
|
||||
augroup END
|
||||
endif
|
||||
|
||||
" EasyClip settings
|
||||
nmap M <Plug>MoveMotionEndOfLinePlug
|
||||
nnoremap gm m
|
||||
|
||||
|
||||
|
||||
" treesitter syntax highlighting
|
||||
lua << EOF
|
||||
require'nvim-treesitter.configs'.setup {
|
||||
highlight = {
|
||||
enable = true, -- Enable Tree-sitter based highlighting
|
||||
},
|
||||
ensure_installed = {"yaml"}, -- Ensure YAML syntax is supported for GitHub Actions
|
||||
}
|
||||
EOF
|
||||
|
||||
|
||||
|
||||
"set relativenumber
|
||||
|
||||
" SETS
|
||||
"set startdir=$NVIM_PWD
|
||||
|
||||
"set number
|
||||
"set relativenumber
|
||||
|
||||
"set statusline=%!MyStatusLine()
|
||||
"function! MyStatusLine()
|
||||
set statusline+=%F
|
||||
let g:netrw_keepdir= 0
|
||||
|
||||
" this should open help in a vertical split
|
||||
set splitright
|
||||
|
||||
"FOLDING
|
||||
set viminfo+=n~/.vim/viminfo
|
||||
set foldenable
|
||||
set foldmethod=manual
|
||||
|
||||
function! ToggleAllFolds()
|
||||
" Check if there are any closed folds
|
||||
if foldclosed('.') != -1
|
||||
" If there are, open all folds
|
||||
normal zR
|
||||
else
|
||||
" Otherwise, close all folds
|
||||
normal zM
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap ZA :call ToggleAllFolds()<CR>
|
||||
|
||||
" Fold remaps
|
||||
"nnoremap ZA zR
|
||||
nnoremap ZD zE
|
||||
nnoremap zG VGo:fold<CR>
|
||||
nnoremap zgg Vgg:fold<CR>
|
||||
"set foldmarker=BEGIN_FOLD,END_FOLD
|
||||
" Managing Manual Folds:
|
||||
"za: Toggle fold under the cursor.
|
||||
"zR: Open all folds.
|
||||
"zM: Close all folds.
|
||||
"zo: Open fold under the cursor.
|
||||
"zc: Close fold under the cursor.
|
||||
"zd: Delete the fold at the cursor.
|
||||
"zE: Erase all folds in the file.
|
||||
"zj: Move to the start of the next fold.
|
||||
"zk: Move to the end of the previous fold.
|
||||
|
||||
set formatoptions-=cro
|
||||
set nopaste
|
||||
"set splitright
|
||||
"set tabline
|
||||
set conceallevel=0
|
||||
set autochdir
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set tabstop=4 softtabstop=4 shiftwidth=2
|
||||
set mouse=a
|
||||
set indentexpr=''
|
||||
"set expandtab
|
||||
"set autoindent
|
||||
"set smarttab
|
||||
"set incsearch ignorecase smartcase hlsearch
|
||||
set nohlsearch
|
||||
"set hlsearch!
|
||||
set wildmode=longest,list,full wildmenu
|
||||
set ruler laststatus=2 showcmd showmode
|
||||
set list listchars=trail:»,tab:»-
|
||||
set fillchars+=vert:\
|
||||
set wrap breakindent
|
||||
set encoding=utf-8
|
||||
set textwidth=0
|
||||
set nohidden
|
||||
set title
|
||||
set undodir=~/.vim/undodir "I need to set up this directory
|
||||
set undofile
|
||||
set incsearch
|
||||
set backspace
|
||||
set autoread
|
||||
set scrolloff=10
|
||||
set colorcolumn=120
|
||||
set clipboard=unnamed,unnamedplus
|
||||
""" Coloring
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
set nocindent
|
||||
set showbreak=>>
|
||||
"set nosmartindent
|
||||
"set noautoindent
|
||||
"set indentexpr=
|
||||
"filetype indent off
|
||||
"filetype plugin indent off
|
||||
|
||||
lua require ('init')
|
||||
let g:coq_settings = { 'auto_start': v:true }
|
||||
|
||||
"return to previous place in buffer
|
||||
|
||||
""" Main Configurations
|
||||
"filetype plugin indent on
|
||||
|
||||
" Functions and autocmds to run whenever changing colorschemes
|
||||
function! TransparentBackground()
|
||||
highlight Normal guibg=NONE ctermbg=NONE
|
||||
highlight LineNr guibg=NONE ctermbg=NONE
|
||||
set fillchars+=vert:\│
|
||||
highlight VertSplit gui=NONE guibg=NONE guifg=#444444 cterm=NONE ctermbg=NONE ctermfg=gray
|
||||
endfunction
|
||||
|
||||
autocmd ColorScheme * call TransparentBackground() " uncomment if you are using a translucent terminal and you want nvim to use that
|
||||
|
||||
set relativenumber
|
||||
|
||||
"nnoremap <leader>th :lua requre('tmux_split_even_horizontal').tmux_split_even_horizontal()<CR>
|
||||
"nnoremap <leader>s :lua require('toggle_rel_abs_numbers').toggle_rel_abs_numbers()<CR>
|
||||
|
||||
"function! ToggleLineNumbers()
|
||||
"if &relativenumber
|
||||
"set norelativenumber
|
||||
"set number
|
||||
"else
|
||||
"set relativenumber
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
nnoremap <leader><leader>n :lua require('toggle_rel_abs_numbers').toggle_line_numbers()<CR>
|
||||
|
||||
" Main Coloring Configurations
|
||||
syntax on
|
||||
color gruvbox
|
||||
|
||||
|
||||
" Enable True Color Support (ensure you're using a 256-color enabled $TERM, e.g. xterm-256color)
|
||||
set termguicolors
|
||||
"
|
||||
"CURSOR SETTINGS
|
||||
"cursor settings MUST COME AFTER set TERMGUICOLORS
|
||||
"https://github.com/neovim/neovim/wiki/FAQ#nvim-shows-weird-symbols-2-q-when-changing-modes
|
||||
"highlight Cursor guifg=blue guibg=blue
|
||||
"set guicursor=i:block-Cursor-blinkon1
|
||||
"set guicursor=i:hor
|
||||
highlight Cursor guifg=blue guibg=blue
|
||||
autocmd InsertEnter * set cul
|
||||
autocmd InsertLeave * set nocul
|
||||
|
||||
" REMAPS
|
||||
nnoremap <leader>gf :Telescope git_files<cr>
|
||||
|
||||
"Harpoon
|
||||
nnoremap <leader>pf :lua require("harpoon.mark").add_file()<cr>
|
||||
nnoremap <leader>pf :lua require("harpoon.ui").toggle_quick_menu()
|
||||
nnoremap <leader>pf :lua require("harpoon.ui").toggle_quick_menu()
|
||||
|
||||
|
||||
"set timeout timeoutlen=1000 ttimeoutlen=100
|
||||
"inoremap <C-c> <Esc>:w<CR>
|
||||
"
|
||||
"save with ctrl s
|
||||
nnoremap <C-s> <C-c>:mkview<CR><C-c>:w<CR>
|
||||
inoremap <C-c> <Esc><right>
|
||||
inoremap <Esc> <Esc><right>
|
||||
|
||||
|
||||
"netrw to automatically change working directory
|
||||
au FileType netrw nmap <buffer> <leader>% mt:!tmux split-window -h;tmux select-layout even-horizontal<CR>
|
||||
au FileType netrw nmap <buffer> <leader>z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"open current NETRW directory in a new tab
|
||||
nnoremap <leader>z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"open current NETRW directory in a new tab
|
||||
nnoremap <leader>% mt:!tmux split-window -h;tmux select-layout even-horizontal<CR>
|
||||
|
||||
"ends up going to the same directory but doesn't open a file
|
||||
"function! OpenInTmuxPane()
|
||||
"" Get the full path of the current file
|
||||
""let l:filepath = netrw#LocalBrowseCheck("")
|
||||
""echo l:filepath
|
||||
"let l:filepath = expand('%:p')
|
||||
|
||||
"" Prepare the tmux command
|
||||
"let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'"
|
||||
|
||||
"" Call the command
|
||||
"call system(l:tmux_command)
|
||||
"endfunction
|
||||
|
||||
function! OpenInTmuxPane()
|
||||
" Get the current directory from the netrw buffer
|
||||
let l:current_dir = b:netrw_curdir
|
||||
|
||||
" Get the name of the file under the cursor
|
||||
let l:filename = expand('<cfile>')
|
||||
|
||||
" Combine the directory and filename to get the full path
|
||||
let l:filepath = l:current_dir . '/' . l:filename
|
||||
|
||||
" Prepare the tmux command
|
||||
let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'"
|
||||
|
||||
" Call the command
|
||||
call system(l:tmux_command)
|
||||
endfunction
|
||||
|
||||
nnoremap <leader>4 :call OpenInTmuxPane()<CR>
|
||||
|
||||
"netrw copy a file
|
||||
au FileType netrw nmap <buffer> <leader>yp mt:!cp -r <C-R><C-F> ./<C-R><C-F>
|
||||
"netrw delete under cursor
|
||||
au FileType netrw nmap <buffer> <leader>x mt:!rm -rf <C-R><C-F><CR><CR>
|
||||
"netrw mkdir command
|
||||
au FileType netrw nmap <buffer> <leader>mkdir mt:!mkdir -p
|
||||
|
||||
":!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"OVERCOMING ANNOYING LITTLE VIM THINGS
|
||||
"nnoremap <CR> <CR><left>
|
||||
"inoremap <CR> <CR><left>
|
||||
"nnoremap o o<left>
|
||||
|
||||
"highlight search settings
|
||||
"highlight link Searchlight Incsearch
|
||||
"hi Search guibg=white guifg=green
|
||||
"hi Search cterm=NONE ctermfg=grey ctermbg=blue
|
||||
""" PLUGIN CONFIGURATIONS
|
||||
|
||||
"let ctrlp search for hidden files and directories
|
||||
let g:ctrlp_show_hidden = 1
|
||||
|
||||
" Neovim :Terminal
|
||||
tmap <Esc> <C-\><C-n>
|
||||
"tmap <C-w> <Esc><C-w>
|
||||
"tmap <C-d> <Esc>:q<CR>
|
||||
|
||||
"delete
|
||||
"I don't know what this does...
|
||||
"autocmd BufWinEnter,WinEnter term://* startinsert
|
||||
"autocmd BufLeave term://* stopinsert
|
||||
|
||||
" vim-pydocstring
|
||||
let g:pydocstring_doq_path = '~/.config/nvim/env/bin/doq'
|
||||
|
||||
" delete
|
||||
" Supertab
|
||||
"let g:SuperTabDefaultCompletionType = "<C-n>"
|
||||
|
||||
" EasyAlign
|
||||
xmap ga <Plug>(EasyAlign)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
|
||||
" indentLine
|
||||
let g:indentLine_char = '▏'
|
||||
let g:indentLine_defaultGroup = 'NonText'
|
||||
" Disable indentLine from concealing json and markdown syntax (e.g. ```)
|
||||
"let g:vim_json_syntax_conceal = 0
|
||||
"let g:vim_markdown_conceal = 0
|
||||
"let g:vim_markdown_conceal_code_blocks = 0
|
||||
|
||||
" TagBar
|
||||
let g:tagbar_width = 40
|
||||
|
||||
" Limelight
|
||||
let g:limelight_conceal_ctermfg = 'gray'
|
||||
let g:limelight_conceal_guifg = 'gray'
|
||||
nmap <Leader>l :Limelight!!<CR>
|
||||
xmap <Leader>l :Limelight!!<CR>
|
||||
autocmd! User GoyoEnter Limelight
|
||||
autocmd! User GoyoLeave Limelight!
|
||||
" Startify
|
||||
"let g:startify_fortune_use_unicode = 1
|
||||
|
||||
"" Startify + NERDTree on start when no file is specified
|
||||
"let &tags = expand("%:p")
|
||||
|
||||
"COC VIM START
|
||||
|
||||
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
" delays and poor user experience.
|
||||
set updatetime=300
|
||||
|
||||
" Don't pass messages to |ins-completion-menu|.
|
||||
set shortmess+=c
|
||||
|
||||
" Always show the signcolumn, otherwise it would shift the text each time
|
||||
" diagnostics appear/become resolved.
|
||||
if has("nvim-0.5.0") || has("patch-8.1.1564")
|
||||
"" Recently vim can merge signcolumn and number column into one
|
||||
set signcolumn=number
|
||||
else
|
||||
set signcolumn=yes
|
||||
endif
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
" other plugin before putting this into your config.
|
||||
"inoremap <silent><expr> <TAB>
|
||||
"\ pumvisible() ? "\<C-n>" :
|
||||
"\ <SID>check_back_space() ? "\<TAB>" :
|
||||
"\ coc#refresh()
|
||||
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
"function! s:check_back_space() abort
|
||||
"let col = col('.') - 1
|
||||
"return !col || getline('.')[col - 1] =~# '\s'
|
||||
"endfunction
|
||||
|
||||
" Use <c-space> to trigger completion.
|
||||
"if has('nvim')
|
||||
""inoremap <silent><expr> <c-space> coc#refresh()
|
||||
"else
|
||||
""inoremap <silent><expr> <c-@> coc#refresh()
|
||||
"endif
|
||||
|
||||
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
||||
" format on enter, <cr> could be remapped by other vim plugin
|
||||
"inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
""\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" GoTo code navigation.
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gt <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window.
|
||||
"nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
"function! s:show_documentation()
|
||||
"if (index(['vim','help'], &filetype) >= 0)
|
||||
"execute 'h '.expand('<cword>')
|
||||
"elseif (coc#rpc#ready())
|
||||
"call CocActionAsync('doHover')
|
||||
"else
|
||||
"execute '!' . &keywordprg . " " . expand('<cword>')
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
" Highlight the symbol and its references when holding the cursor.
|
||||
"autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Symbol renaming.
|
||||
"nnoremap <leader>9 <Plug>(coc-rename)
|
||||
"nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Formatting selected code.
|
||||
"xmap <leader>= <Plug>(coc-format-selected)
|
||||
"nmap <leader>= <Plug>(coc-format-selected)
|
||||
|
||||
"augroup mygroup
|
||||
"autocmd!
|
||||
""" Setup formatexpr specified filetype(s).
|
||||
"autocmd FileType typescript,json,python,yaml setl formatexpr=CocAction('formatSelected')
|
||||
""" Update signature help on jump placeholder.
|
||||
"autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
"augroup end
|
||||
|
||||
"let g:python3_host_prog = "/usr/bin/python3.8"
|
||||
" coc.vim END
|
||||
|
||||
" signify
|
||||
"let g:signify_sign_add = '│'
|
||||
"let g:signify_sign_delete = '│'
|
||||
"let g:signify_sign_change = '│'
|
||||
"hi DiffDelete guifg=#ff5555 guibg=none
|
||||
|
||||
" FixCursorHold for better performance
|
||||
let g:cursorhold_updatetime = 100
|
||||
|
||||
" context.vim
|
||||
let g:context_nvim_no_redraw =1
|
||||
|
||||
""" Filetype-Specific Configurations
|
||||
|
||||
" HTML, XML, Jinja
|
||||
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType xml setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType htmldjango inoremap {{ {{ }}<left><left><left>
|
||||
autocmd FileType htmldjango inoremap {% {% %}<left><left><left>
|
||||
autocmd FileType htmldjango inoremap {# {# #}<left><left><left>
|
||||
|
||||
" Markdown and Journal
|
||||
autocmd FileType markdown setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType journal setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
|
||||
""" Custom Functions
|
||||
|
||||
" Trim Whitespaces
|
||||
"function! TrimWhitespace()
|
||||
"let l:save = winsaveview()
|
||||
"%s/\\\@<!\s\+$//e
|
||||
"call winrestview(l:save)
|
||||
"endfunction
|
||||
|
||||
""" CUSTOM MAPPINGS
|
||||
|
||||
"open up a terminal
|
||||
nmap <leader><C-t> <c-W>s<C-w>j:terminal<CR>:set nonumber<CR><S-a>
|
||||
nmap <C-t> <C-w>v<C-w>l:terminal<CR>:set nonumber<CR><S-a>
|
||||
|
||||
" NerdTree
|
||||
"nmap <leader>q :NERDTreeToggle<CR>
|
||||
"nnoremap <leader>e :NERDTreeFocus<CR>
|
||||
"nnoremap <C-f> :NERDTreeFind<CR> """open NerdTree current directory"""
|
||||
"nmap \\ <leader>q
|
||||
"
|
||||
"CHADtree
|
||||
"let &tags = expand("%:p")
|
||||
"nnoremap <leader>e :CHADopen<CR>
|
||||
"nnoremap <leader>3 :CHADopen --always-focus<CR>
|
||||
|
||||
"nnoremap <leader>e :Vexplore<CR><C-w>r
|
||||
"nnoremap <leader>E :Ex<CR>
|
||||
|
||||
"Tagbar
|
||||
"nmap <leader>w :TagbarToggle<CR>
|
||||
"nmap \| <leader>w
|
||||
|
||||
"Source vim
|
||||
nmap <leader>R :so ~/.config/nvim/init.vim<CR>
|
||||
|
||||
|
||||
"nmap <leader>t :call TrimWhitespace()<CR>
|
||||
"nmap <leader>y <C-w>v<C-w>l:HackerNews best<CR>J
|
||||
"nmap <leader>p <Plug>(pydocstring)
|
||||
|
||||
"easy align
|
||||
xmap <leader>a gaip*
|
||||
nmap <leader>a gaip*
|
||||
"nmap <leader>s :Rg<CR>
|
||||
|
||||
"scroll sync lock
|
||||
nnoremap <leader><leader>sl :set scb!<CR>
|
||||
|
||||
"quick grep search
|
||||
"all system files -- not useful
|
||||
"nmap <leader>d :Files<CR>
|
||||
"nnoremap <silent> <Leader>h: :History:<CR>
|
||||
"nnoremap <silent> <Leader>h/ :History/<CR>
|
||||
""latest files -- very useful!
|
||||
"nnoremap <silent> <Leader>hh :History<CR>
|
||||
""find file in line
|
||||
"nmap <leader>z :BLines<CR>
|
||||
"nmap <leader>H :RainbowParentheses!!<CR>
|
||||
"nnoremap """ :reg<CR>
|
||||
"
|
||||
|
||||
|
||||
"nmap <leader>g :Goyo<CR>
|
||||
"nmap <leader>j :set filetype=journal<CR>
|
||||
"nmap <leader>l :Limelight!!<CR>
|
||||
"xmap <leader>l :Limelight!!<CR>
|
||||
"
|
||||
"I actually don't like what this does. It makes the python indent all weird.
|
||||
"Figure out what plugin would cause indent to be like this, then delete it.
|
||||
"I still have an annoying indentation error when I'm typing as well.
|
||||
"autocmd FileType python nmap <leader>x :0,$!~/.config/nvim/env/bin/python -m yapf<CR>
|
||||
|
||||
nmap <silent> <leader>no :set hlsearch!<CR>
|
||||
|
||||
"nmap <Tab> :tabn<CR>
|
||||
"nmap <S-Tset -g status-left "#{pane_current_path}"ab> :tabp<CR>
|
||||
|
||||
" view current buffers and type the number you want to go to.
|
||||
":bd to delete a single buffer
|
||||
nnoremap <F5> :buffers<CR>:buffer<Space>
|
||||
|
||||
"go back to file tree
|
||||
"nnoremap <C-e> :Ex
|
||||
|
||||
"splits
|
||||
nnoremap <leader><C-v> :vsplit<CR>
|
||||
"nnoremap <leader><C-h> <C-w><s>
|
||||
|
||||
"Navigate split buffers
|
||||
"Normal Mode
|
||||
nnoremap <C-j> <C-w><C-j>
|
||||
nnoremap <C-k> <C-W><C-k>
|
||||
nnoremap <C-l> <C-W><C-l>
|
||||
nnoremap <C-h> <C-W><C-h>
|
||||
"Terminal mode
|
||||
tnoremap <C-j> <C-\><C-n><C-W><C-J>
|
||||
tnoremap <C-k> <C-\><C-n><C-W><C-K>
|
||||
tnoremap <C-l> <C-\><C-n><C-W><C-L>
|
||||
tnoremap <C-h> <C-\><C-n><C-W><C-H>
|
||||
|
||||
|
||||
"add current cursor position to jumplist
|
||||
nnoremap <Leader>m :autocmd CursorHold * normal! m'<CR>
|
||||
|
||||
|
||||
""easymotion mappings
|
||||
"let g:EasyMotion_do_mapping = 0 " Disable default mappings
|
||||
"nnoremap <Leader>f <Plug>(easymotion-prefix)f
|
||||
"nnoremap <Leader>s <Plug>(easymotion-s2)
|
||||
"nnoremap <Leader>f <Plug>(easymotion-prefix)s
|
||||
"nnoremap <c-_> <Plug>(easymotion-sn)
|
||||
"nnoremap <Leader>/ <Plug>(easymotion-sn)
|
||||
"nnoremap <Leader>F <Plug>(easymotion-prefix)F
|
||||
"nnoremap <Leader>s <Plug>(easymotion-prefix)s
|
||||
|
||||
|
||||
"map <C-;> <Plug>(easymotion-next)
|
||||
"map <C-,> <Plug>(easymotion-prev)" Terminal mode:
|
||||
"nmap <leader>f <Plug>(easymotion-overwin-f)
|
||||
"nmap <leader>cf c<Plug>(easymotion-overwin-f)
|
||||
"nmap s <Plug>(easymotion-overwin-f2)
|
||||
" Turn on case-insensitive feature
|
||||
let g:EasyMotion_smartcase = 1
|
||||
|
||||
"fuzzy finder
|
||||
"I have to remap ctrlp's default in order to make my custom command to work
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
"open up all files including dotfiles
|
||||
nnoremap <leader>p :CtrlP /home/ldraney<CR>
|
||||
set wildignore+=*/.vim/*
|
||||
"
|
||||
|
||||
"Rename tmux window tab after current file with path
|
||||
"autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window " . expand("%:t"))
|
||||
|
||||
|
||||
let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
|
||||
|
||||
nnoremap <leader><leader>c GVggc
|
|
@ -0,0 +1,671 @@
|
|||
" VIM RECORDING
|
||||
"q<letter> to start recording
|
||||
"q to stop recording
|
||||
"@<letter> to play back recording
|
||||
|
||||
|
||||
"function! TmuxSplitEvenHorizontal()
|
||||
"let filepath = expand('%:p')
|
||||
"if !empty(filepath)
|
||||
"let tmux_command = "tmux split-window -h -c '#{pane_current_path}' 'nvim ".filepath."' && tmux select-layout even-horizontal"
|
||||
"call system(tmux_command)
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
function! TmuxSplitEvenHorizontal()
|
||||
let filepath = expand('%:p')
|
||||
if !empty(filepath)
|
||||
let tmux_command = "tmux split-window -h -c '".expand('%:p:h')."' && tmux send-keys -t '.tmux.active-pane' 'nvim ".shellescape(filepath)."' Enter && tmux select-layout even-horizontal"
|
||||
call system(tmux_command)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <leader>th :call TmuxSplitEvenHorizontal()<CR>
|
||||
|
||||
function! ToggleRelAbsNumbers()
|
||||
set relativenumber
|
||||
set number
|
||||
else
|
||||
set norelativenumber
|
||||
set nonumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <leader>s :call ToggleRelAbsNumbers()<CR>
|
||||
|
||||
|
||||
|
||||
"use alt-/ to search within a highlighted visual field
|
||||
vnoremap <M-/> <Esc>/\%V
|
||||
"
|
||||
"Go to last position in file
|
||||
autocmd BufWinLeave * silent! mkview
|
||||
autocmd BufWinEnter * silent! loadview
|
||||
|
||||
" current directory to match netrw browsing
|
||||
let g:netrw_keepdir= 0
|
||||
|
||||
"give syntax highlighting to sh files with zsh syntax highlighting
|
||||
au BufRead,BufNewFile *.sh setfiletype zsh
|
||||
set syn=sh
|
||||
|
||||
call plug#begin()
|
||||
" relative and absolute line numbers
|
||||
"Plug 'sitiom/nvim-numbertoggle'
|
||||
|
||||
"format json files
|
||||
Plug 'XadillaX/json-formatter.vim'
|
||||
"must also run:
|
||||
"npm install -g jjson
|
||||
"usage:
|
||||
":JSONFormatter"
|
||||
|
||||
Plug 'github/copilot.vim'
|
||||
"must also run:
|
||||
":Copilot setup
|
||||
"# Go to my Microsoft Edge bookmark named "Copilot Login"
|
||||
":Copilot enable
|
||||
|
||||
"format terraform file with a :TerraformFmt ex command
|
||||
"Also include TerraformSyntax highlighting
|
||||
Plug 'hashivim/vim-terraform'
|
||||
|
||||
"bash script syntax highlighting
|
||||
"Plug 'godlygeek/tabular'
|
||||
"Plug 'arzg/vim-sh'
|
||||
|
||||
" Telescope stuff
|
||||
Plug 'nvim-lua/plenary.nvim'
|
||||
Plug 'nvim-telescope/telescope.nvim', { 'tag': '0.1.0' }
|
||||
Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' }
|
||||
Plug 'ThePrimeagen/harpoon'
|
||||
"Start using vim with googgle docs :)))
|
||||
"Plug 'aadv1k/gdoc.vim', {'do': './install.py'}
|
||||
|
||||
"LSP stuff
|
||||
"Plug 'neoclide/coc.nvim', {'branch': 'release'}
|
||||
"Plug 'neovim/nvim-lspconfig'
|
||||
|
||||
" AUTOCOMPLETE STUFF?
|
||||
"Plug 'hrsh7th/nvim-cmp'
|
||||
"Plug 'williamboman/nvim-lsp-installer'
|
||||
"Plug 'tami5/lspsaga.nvim'
|
||||
"Plug 'simrat39/symbols-outline.nvim'
|
||||
"Plug 'hrsh7th/nvim-cmp'
|
||||
"Plug 'hrsh7th/cmp-nvim-lsp'
|
||||
"Plug 'saadparwaiz1/cmp_luasnip'
|
||||
"Plug 'L3MON4D3/LuaSnip'
|
||||
"Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
|
||||
"Plug 'ms-jpq/coq.artifacts', {'branch': 'artifacts'}
|
||||
"Plug 'ms-jpq/coq.thirdparty', {'branch': '3p'}
|
||||
"Plug 'heavenshell/vim-pydocstring', { 'do': 'make install' }
|
||||
"
|
||||
"Debugger
|
||||
"Plug 'puremourning/vimspector'
|
||||
|
||||
" AESTHETICS
|
||||
Plug 'gruvbox-community/gruvbox'
|
||||
|
||||
"highlighting plugins that may be useful when I'm a senior dev
|
||||
Plug 'junegunn/goyo.vim'
|
||||
Plug 'junegunn/limelight.vim'
|
||||
Plug 'junegunn/rainbow_parentheses.vim'
|
||||
|
||||
" FILE FORMATTING AND VISUAL HELPS
|
||||
|
||||
"smooth scrolling
|
||||
Plug 'psliwka/vim-smoothie'
|
||||
|
||||
"search blink
|
||||
Plug 'ivyl/vim-bling'
|
||||
|
||||
Plug 'antoinemadec/FixCursorHold.nvim'
|
||||
"
|
||||
"Super handy. Shows the current function or class when scrolling down
|
||||
Plug 'wellle/context.vim'
|
||||
|
||||
"useful for aligning dictionaries or other declarations
|
||||
"Plug 'junegunn/vim-easy-align'
|
||||
|
||||
Plug 'lukas-reineke/indent-blankline.nvim'
|
||||
|
||||
" Automatic numbering and bullet points for new lines
|
||||
"Plug 'dkarter/bullets.vim'
|
||||
|
||||
" FUNCTIONALITIES
|
||||
Plug 'tpope/vim-repeat'
|
||||
"
|
||||
Plug 'ctrlpvim/ctrlp.vim'
|
||||
Plug 'preservim/nerdcommenter'
|
||||
Plug 'svermeulen/vim-easyclip' "Fixes the clipboard functionality
|
||||
|
||||
"Useful vim surround Keys:
|
||||
"1. cs"' to change the outer characters of current sentence
|
||||
"2. ds" to delete outer characters entirely
|
||||
"3. ysiw" to "surround current" word with "
|
||||
"4. yssb or yss( to wrap entire line with parenthesis
|
||||
"5. S" in visual mode will surround with quotes
|
||||
Plug 'tpope/vim-surround'
|
||||
|
||||
"shows an outline of imports, functions, and classes by scope
|
||||
Plug 'majutsushi/tagbar'
|
||||
|
||||
" git assistant
|
||||
Plug 'tpope/vim-fugitive'
|
||||
|
||||
"Plug 'ryanoasis/vim-devicons'
|
||||
"Plug 'kyazdani42/nvim-web-devicons'
|
||||
|
||||
"Plug 'junegunn/fzf', { 'do': { -> fzf#install() } }
|
||||
Plug 'junegunn/fzf.vim'
|
||||
|
||||
call plug#end()
|
||||
|
||||
" Enable automatic formatting of Terraform files on save
|
||||
let g:terraform_fmt_on_save = 1
|
||||
|
||||
"system clipboard on wsl2
|
||||
if system('uname -r') =~ "microsoft"
|
||||
augroup Yank
|
||||
autocmd!
|
||||
autocmd TextYankPost * :call system('/mnt/c/windows/system32/clip.exe ',@")
|
||||
augroup END
|
||||
endif
|
||||
|
||||
|
||||
|
||||
" SETS
|
||||
"set startdir=$NVIM_PWD
|
||||
|
||||
set writebackup
|
||||
set patchmode=.orig
|
||||
set backupcopy=yes
|
||||
set backupdir=~/Backups
|
||||
|
||||
"set number
|
||||
"set relativenumber
|
||||
|
||||
"set statusline=%!MyStatusLine()
|
||||
"function! MyStatusLine()
|
||||
set statusline+=%F
|
||||
let g:netrw_keepdir= 0
|
||||
|
||||
" this should open help in a vertical split
|
||||
set splitright
|
||||
|
||||
set formatoptions-=cro
|
||||
set nopaste
|
||||
"set splitright
|
||||
"set tabline
|
||||
set conceallevel=0
|
||||
set autochdir
|
||||
set ignorecase
|
||||
set smartcase
|
||||
set tabstop=4 softtabstop=4 shiftwidth=2
|
||||
set mouse=a
|
||||
set indentexpr=''
|
||||
"set expandtab
|
||||
"set autoindent
|
||||
"set smarttab
|
||||
"set incsearch ignorecase smartcase hlsearch
|
||||
set nohlsearch
|
||||
"set hlsearch!
|
||||
set wildmode=longest,list,full wildmenu
|
||||
set ruler laststatus=2 showcmd showmode
|
||||
set list listchars=trail:»,tab:»-
|
||||
set fillchars+=vert:\
|
||||
set wrap breakindent
|
||||
set encoding=utf-8
|
||||
set textwidth=0
|
||||
set nohidden
|
||||
set title
|
||||
set undodir=~/.vim/undodir "I need to set up this directory
|
||||
set undofile
|
||||
set incsearch
|
||||
set backspace
|
||||
set autoread
|
||||
set scrolloff=10
|
||||
set colorcolumn=80
|
||||
set clipboard=unnamed,unnamedplus
|
||||
""" Coloring
|
||||
set splitbelow
|
||||
set splitright
|
||||
|
||||
set nocindent
|
||||
set showbreak=>>
|
||||
"set nosmartindent
|
||||
"set noautoindent
|
||||
"set indentexpr=
|
||||
"filetype indent off
|
||||
"filetype plugin indent off
|
||||
|
||||
lua require ('init')
|
||||
let g:coq_settings = { 'auto_start': v:true }
|
||||
|
||||
"return to previous place in buffer
|
||||
|
||||
""" Main Configurations
|
||||
"filetype plugin indent on
|
||||
|
||||
"nmap M <Plug>MoveMotionEndOfLinePlug
|
||||
|
||||
" Functions and autocmds to run whenever changing colorschemes
|
||||
function! TransparentBackground()
|
||||
highlight Normal guibg=NONE ctermbg=NONE
|
||||
highlight LineNr guibg=NONE ctermbg=NONE
|
||||
set fillchars+=vert:\│
|
||||
highlight VertSplit gui=NONE guibg=NONE guifg=#444444 cterm=NONE ctermbg=NONE ctermfg=gray
|
||||
endfunction
|
||||
|
||||
autocmd ColorScheme * call TransparentBackground() " uncomment if you are using a translucent terminal and you want nvim to use that
|
||||
|
||||
set relativenumber
|
||||
|
||||
function! ToggleLineNumbers()
|
||||
if &relativenumber
|
||||
set norelativenumber
|
||||
set number
|
||||
else
|
||||
set relativenumber
|
||||
endif
|
||||
endfunction
|
||||
|
||||
nnoremap <leader><leader>n :call ToggleLineNumbers()<CR>
|
||||
|
||||
" Main Coloring Configurations
|
||||
syntax on
|
||||
color gruvbox
|
||||
|
||||
|
||||
" Enable True Color Support (ensure you're using a 256-color enabled $TERM, e.g. xterm-256color)
|
||||
set termguicolors
|
||||
"
|
||||
"CURSOR SETTINGS
|
||||
"cursor settings MUST COME AFTER set TERMGUICOLORS
|
||||
"https://github.com/neovim/neovim/wiki/FAQ#nvim-shows-weird-symbols-2-q-when-changing-modes
|
||||
"highlight Cursor guifg=blue guibg=blue
|
||||
"set guicursor=i:block-Cursor-blinkon1
|
||||
"set guicursor=i:hor
|
||||
highlight Cursor guifg=blue guibg=blue
|
||||
autocmd InsertEnter * set cul
|
||||
autocmd InsertLeave * set nocul
|
||||
|
||||
" REMAPS
|
||||
nnoremap <leader>gf :Telescope git_files<cr>
|
||||
|
||||
"Harpoon
|
||||
nnoremap <leader>pf :lua require("harpoon.mark").add_file()<cr>
|
||||
nnoremap <leader>pf :lua require("harpoon.ui").toggle_quick_menu()
|
||||
nnoremap <leader>pf :lua require("harpoon.ui").toggle_quick_menu()
|
||||
|
||||
|
||||
"set timeout timeoutlen=1000 ttimeoutlen=100
|
||||
"inoremap <C-c> <Esc>:w<CR>
|
||||
"
|
||||
"save with ctrl s
|
||||
nnoremap <C-s> <C-c>:w<CR>
|
||||
inoremap <C-c> <Esc><right>
|
||||
inoremap <Esc> <Esc><right>
|
||||
|
||||
|
||||
"netrw to automatically change working directory
|
||||
au FileType netrw nmap <buffer> <leader>% mt:!tmux split-window -h;tmux select-layout even-horizontal<CR>
|
||||
au FileType netrw nmap <buffer> <leader>z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"open current NETRW directory in a new tab
|
||||
nnoremap <leader>z mt:!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"open current NETRW directory in a new tab
|
||||
nnoremap <leader>% mt:!tmux split-window -h;tmux select-layout even-horizontal<CR>
|
||||
|
||||
"ends up going to the same directory but doesn't open a file
|
||||
"function! OpenInTmuxPane()
|
||||
"" Get the full path of the current file
|
||||
""let l:filepath = netrw#LocalBrowseCheck("")
|
||||
""echo l:filepath
|
||||
"let l:filepath = expand('%:p')
|
||||
|
||||
"" Prepare the tmux command
|
||||
"let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'"
|
||||
|
||||
"" Call the command
|
||||
"call system(l:tmux_command)
|
||||
"endfunction
|
||||
|
||||
function! OpenInTmuxPane()
|
||||
" Get the current directory from the netrw buffer
|
||||
let l:current_dir = b:netrw_curdir
|
||||
|
||||
" Get the name of the file under the cursor
|
||||
let l:filename = expand('<cfile>')
|
||||
|
||||
" Combine the directory and filename to get the full path
|
||||
let l:filepath = l:current_dir . '/' . l:filename
|
||||
|
||||
" Prepare the tmux command
|
||||
let l:tmux_command = "tmux split-window -h 'nvim " . l:filepath . "'"
|
||||
|
||||
" Call the command
|
||||
call system(l:tmux_command)
|
||||
endfunction
|
||||
|
||||
nnoremap <leader>4 :call OpenInTmuxPane()<CR>
|
||||
|
||||
"netrw copy a file
|
||||
au FileType netrw nmap <buffer> <leader>yp mt:!cp -r <C-R><C-F> ./<C-R><C-F>
|
||||
"netrw delete under cursor
|
||||
au FileType netrw nmap <buffer> <leader>x mt:!rm -rf <C-R><C-F><CR><CR>
|
||||
"netrw mkdir command
|
||||
au FileType netrw nmap <buffer> <leader>mkdir mt:!mkdir -p
|
||||
|
||||
":!tmux split-window -h; tmux select-pane -L; tmux kill-pane; tmux select-layout even-horizontal<CR>
|
||||
"OVERCOMING ANNOYING LITTLE VIM THINGS
|
||||
"nnoremap <CR> <CR><left>
|
||||
"inoremap <CR> <CR><left>
|
||||
"nnoremap o o<left>
|
||||
|
||||
"highlight search settings
|
||||
"highlight link Searchlight Incsearch
|
||||
"hi Search guibg=white guifg=green
|
||||
"hi Search cterm=NONE ctermfg=grey ctermbg=blue
|
||||
""" PLUGIN CONFIGURATIONS
|
||||
|
||||
"let ctrlp search for hidden files and directories
|
||||
let g:ctrlp_show_hidden = 1
|
||||
|
||||
" Neovim :Terminal
|
||||
tmap <Esc> <C-\><C-n>
|
||||
"tmap <C-w> <Esc><C-w>
|
||||
"tmap <C-d> <Esc>:q<CR>
|
||||
|
||||
"delete
|
||||
"I don't know what this does...
|
||||
"autocmd BufWinEnter,WinEnter term://* startinsert
|
||||
"autocmd BufLeave term://* stopinsert
|
||||
|
||||
" vim-pydocstring
|
||||
let g:pydocstring_doq_path = '~/.config/nvim/env/bin/doq'
|
||||
|
||||
" delete
|
||||
" Supertab
|
||||
"let g:SuperTabDefaultCompletionType = "<C-n>"
|
||||
|
||||
" EasyAlign
|
||||
xmap ga <Plug>(EasyAlign)
|
||||
nmap ga <Plug>(EasyAlign)
|
||||
|
||||
" indentLine
|
||||
let g:indentLine_char = '▏'
|
||||
let g:indentLine_defaultGroup = 'NonText'
|
||||
" Disable indentLine from concealing json and markdown syntax (e.g. ```)
|
||||
"let g:vim_json_syntax_conceal = 0
|
||||
"let g:vim_markdown_conceal = 0
|
||||
"let g:vim_markdown_conceal_code_blocks = 0
|
||||
|
||||
" TagBar
|
||||
let g:tagbar_width = 40
|
||||
|
||||
" Limelight
|
||||
let g:limelight_conceal_ctermfg = 'gray'
|
||||
let g:limelight_conceal_guifg = 'gray'
|
||||
nmap <Leader>l :Limelight!!<CR>
|
||||
xmap <Leader>l :Limelight!!<CR>
|
||||
autocmd! User GoyoEnter Limelight
|
||||
autocmd! User GoyoLeave Limelight!
|
||||
" Startify
|
||||
"let g:startify_fortune_use_unicode = 1
|
||||
|
||||
"" Startify + NERDTree on start when no file is specified
|
||||
"let &tags = expand("%:p")
|
||||
|
||||
"COC VIM START
|
||||
|
||||
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable
|
||||
" delays and poor user experience.
|
||||
set updatetime=300
|
||||
|
||||
" Don't pass messages to |ins-completion-menu|.
|
||||
set shortmess+=c
|
||||
|
||||
" Always show the signcolumn, otherwise it would shift the text each time
|
||||
" diagnostics appear/become resolved.
|
||||
if has("nvim-0.5.0") || has("patch-8.1.1564")
|
||||
"" Recently vim can merge signcolumn and number column into one
|
||||
set signcolumn=number
|
||||
else
|
||||
set signcolumn=yes
|
||||
endif
|
||||
|
||||
" Use tab for trigger completion with characters ahead and navigate.
|
||||
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
|
||||
" other plugin before putting this into your config.
|
||||
"inoremap <silent><expr> <TAB>
|
||||
"\ pumvisible() ? "\<C-n>" :
|
||||
"\ <SID>check_back_space() ? "\<TAB>" :
|
||||
"\ coc#refresh()
|
||||
"inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
|
||||
"function! s:check_back_space() abort
|
||||
"let col = col('.') - 1
|
||||
"return !col || getline('.')[col - 1] =~# '\s'
|
||||
"endfunction
|
||||
|
||||
" Use <c-space> to trigger completion.
|
||||
"if has('nvim')
|
||||
""inoremap <silent><expr> <c-space> coc#refresh()
|
||||
"else
|
||||
""inoremap <silent><expr> <c-@> coc#refresh()
|
||||
"endif
|
||||
|
||||
" Make <CR> auto-select the first completion item and notify coc.nvim to
|
||||
" format on enter, <cr> could be remapped by other vim plugin
|
||||
"inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
|
||||
""\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
|
||||
|
||||
" Use `[g` and `]g` to navigate diagnostics
|
||||
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
|
||||
nmap <silent> [g <Plug>(coc-diagnostic-prev)
|
||||
nmap <silent> ]g <Plug>(coc-diagnostic-next)
|
||||
|
||||
" GoTo code navigation.
|
||||
nmap <silent> gd <Plug>(coc-definition)
|
||||
nmap <silent> gt <Plug>(coc-type-definition)
|
||||
nmap <silent> gi <Plug>(coc-implementation)
|
||||
nmap <silent> gr <Plug>(coc-references)
|
||||
|
||||
" Use K to show documentation in preview window.
|
||||
"nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||
"function! s:show_documentation()
|
||||
"if (index(['vim','help'], &filetype) >= 0)
|
||||
"execute 'h '.expand('<cword>')
|
||||
"elseif (coc#rpc#ready())
|
||||
"call CocActionAsync('doHover')
|
||||
"else
|
||||
"execute '!' . &keywordprg . " " . expand('<cword>')
|
||||
"endif
|
||||
"endfunction
|
||||
|
||||
" Highlight the symbol and its references when holding the cursor.
|
||||
"autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||
|
||||
" Symbol renaming.
|
||||
"nnoremap <leader>9 <Plug>(coc-rename)
|
||||
"nmap <leader>rn <Plug>(coc-rename)
|
||||
|
||||
" Formatting selected code.
|
||||
"xmap <leader>= <Plug>(coc-format-selected)
|
||||
"nmap <leader>= <Plug>(coc-format-selected)
|
||||
|
||||
"augroup mygroup
|
||||
"autocmd!
|
||||
""" Setup formatexpr specified filetype(s).
|
||||
"autocmd FileType typescript,json,python,yaml setl formatexpr=CocAction('formatSelected')
|
||||
""" Update signature help on jump placeholder.
|
||||
"autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
|
||||
"augroup end
|
||||
|
||||
"let g:python3_host_prog = "/usr/bin/python3.8"
|
||||
" coc.vim END
|
||||
|
||||
" signify
|
||||
"let g:signify_sign_add = '│'
|
||||
"let g:signify_sign_delete = '│'
|
||||
"let g:signify_sign_change = '│'
|
||||
"hi DiffDelete guifg=#ff5555 guibg=none
|
||||
|
||||
" FixCursorHold for better performance
|
||||
let g:cursorhold_updatetime = 100
|
||||
|
||||
" context.vim
|
||||
let g:context_nvim_no_redraw =1
|
||||
|
||||
""" Filetype-Specific Configurations
|
||||
|
||||
" HTML, XML, Jinja
|
||||
autocmd FileType html setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType css setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType xml setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType htmldjango setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType htmldjango inoremap {{ {{ }}<left><left><left>
|
||||
autocmd FileType htmldjango inoremap {% {% %}<left><left><left>
|
||||
autocmd FileType htmldjango inoremap {# {# #}<left><left><left>
|
||||
|
||||
" Markdown and Journal
|
||||
autocmd FileType markdown setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
autocmd FileType journal setlocal shiftwidth=2 tabstop=2 softtabstop=2
|
||||
|
||||
""" Custom Functions
|
||||
|
||||
" Trim Whitespaces
|
||||
"function! TrimWhitespace()
|
||||
"let l:save = winsaveview()
|
||||
"%s/\\\@<!\s\+$//e
|
||||
"call winrestview(l:save)
|
||||
"endfunction
|
||||
|
||||
""" CUSTOM MAPPINGS
|
||||
|
||||
"open up a terminal
|
||||
nmap <leader><C-t> <c-W>s<C-w>j:terminal<CR>:set nonumber<CR><S-a>
|
||||
nmap <C-t> <C-w>v<C-w>l:terminal<CR>:set nonumber<CR><S-a>
|
||||
|
||||
" NerdTree
|
||||
"nmap <leader>q :NERDTreeToggle<CR>
|
||||
"nnoremap <leader>e :NERDTreeFocus<CR>
|
||||
"nnoremap <C-f> :NERDTreeFind<CR> """open NerdTree current directory"""
|
||||
"nmap \\ <leader>q
|
||||
"
|
||||
"CHADtree
|
||||
"let &tags = expand("%:p")
|
||||
"nnoremap <leader>e :CHADopen<CR>
|
||||
"nnoremap <leader>3 :CHADopen --always-focus<CR>
|
||||
|
||||
"nnoremap <leader>e :Vexplore<CR><C-w>r
|
||||
"nnoremap <leader>E :Ex<CR>
|
||||
|
||||
"Tagbar
|
||||
"nmap <leader>w :TagbarToggle<CR>
|
||||
"nmap \| <leader>w
|
||||
|
||||
"Source vim
|
||||
nmap <leader>R :so ~/.config/nvim/init.vim<CR>
|
||||
|
||||
|
||||
"nmap <leader>t :call TrimWhitespace()<CR>
|
||||
"nmap <leader>y <C-w>v<C-w>l:HackerNews best<CR>J
|
||||
"nmap <leader>p <Plug>(pydocstring)
|
||||
|
||||
"easy align
|
||||
xmap <leader>a gaip*
|
||||
nmap <leader>a gaip*
|
||||
"nmap <leader>s :Rg<CR>
|
||||
|
||||
"scroll sync lock
|
||||
nnoremap <leader><leader>sl :set scb!<CR>
|
||||
|
||||
"quick grep search
|
||||
"all system files -- not useful
|
||||
"nmap <leader>d :Files<CR>
|
||||
"nnoremap <silent> <Leader>h: :History:<CR>
|
||||
"nnoremap <silent> <Leader>h/ :History/<CR>
|
||||
""latest files -- very useful!
|
||||
"nnoremap <silent> <Leader>hh :History<CR>
|
||||
""find file in line
|
||||
"nmap <leader>z :BLines<CR>
|
||||
"nmap <leader>H :RainbowParentheses!!<CR>
|
||||
"nnoremap """ :reg<CR>
|
||||
"
|
||||
|
||||
|
||||
"nmap <leader>g :Goyo<CR>
|
||||
"nmap <leader>j :set filetype=journal<CR>
|
||||
"nmap <leader>l :Limelight!!<CR>
|
||||
"xmap <leader>l :Limelight!!<CR>
|
||||
"
|
||||
"I actually don't like what this does. It makes the python indent all weird.
|
||||
"Figure out what plugin would cause indent to be like this, then delete it.
|
||||
"I still have an annoying indentation error when I'm typing as well.
|
||||
"autocmd FileType python nmap <leader>x :0,$!~/.config/nvim/env/bin/python -m yapf<CR>
|
||||
|
||||
nmap <silent> <leader>no :set hlsearch!<CR>
|
||||
|
||||
"nmap <Tab> :tabn<CR>
|
||||
"nmap <S-Tset -g status-left "#{pane_current_path}"ab> :tabp<CR>
|
||||
|
||||
" view current buffers and type the number you want to go to.
|
||||
":bd to delete a single buffer
|
||||
nnoremap <F5> :buffers<CR>:buffer<Space>
|
||||
|
||||
"go back to file tree
|
||||
"nnoremap <C-e> :Ex
|
||||
|
||||
"splits
|
||||
nnoremap <leader><C-v> :vsplit<CR>
|
||||
"nnoremap <leader><C-h> <C-w><s>
|
||||
|
||||
"Navigate split buffers
|
||||
"Normal Mode
|
||||
nnoremap <C-j> <C-w><C-j>
|
||||
nnoremap <C-k> <C-W><C-k>
|
||||
nnoremap <C-l> <C-W><C-l>
|
||||
nnoremap <C-h> <C-W><C-h>
|
||||
"Terminal mode
|
||||
tnoremap <C-j> <C-\><C-n><C-W><C-J>
|
||||
tnoremap <C-k> <C-\><C-n><C-W><C-K>
|
||||
tnoremap <C-l> <C-\><C-n><C-W><C-L>
|
||||
tnoremap <C-h> <C-\><C-n><C-W><C-H>
|
||||
|
||||
|
||||
"add current cursor position to jumplist
|
||||
nnoremap <Leader>m :autocmd CursorHold * normal! m'<CR>
|
||||
|
||||
|
||||
""easymotion mappings
|
||||
"let g:EasyMotion_do_mapping = 0 " Disable default mappings
|
||||
"nnoremap <Leader>f <Plug>(easymotion-prefix)f
|
||||
"nnoremap <Leader>s <Plug>(easymotion-s2)
|
||||
"nnoremap <Leader>f <Plug>(easymotion-prefix)s
|
||||
"nnoremap <c-_> <Plug>(easymotion-sn)
|
||||
"nnoremap <Leader>/ <Plug>(easymotion-sn)
|
||||
"nnoremap <Leader>F <Plug>(easymotion-prefix)F
|
||||
"nnoremap <Leader>s <Plug>(easymotion-prefix)s
|
||||
|
||||
|
||||
"map <C-;> <Plug>(easymotion-next)
|
||||
"map <C-,> <Plug>(easymotion-prev)" Terminal mode:
|
||||
"nmap <leader>f <Plug>(easymotion-overwin-f)
|
||||
"nmap <leader>cf c<Plug>(easymotion-overwin-f)
|
||||
"nmap s <Plug>(easymotion-overwin-f2)
|
||||
" Turn on case-insensitive feature
|
||||
let g:EasyMotion_smartcase = 1
|
||||
|
||||
"fuzzy finder
|
||||
"I have to remap ctrlp's default in order to make my custom command to work
|
||||
let g:ctrlp_map = '<c-p>'
|
||||
"open up all files including dotfiles
|
||||
nnoremap <leader>p :CtrlP /home/ldraney<CR>
|
||||
set wildignore+=*/.vim/*
|
||||
"
|
||||
|
||||
"Rename tmux window tab after current file with path
|
||||
"autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window " . expand("%:t"))
|
||||
|
||||
|
||||
let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro'
|
|
@ -0,0 +1,33 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Directories and file names
|
||||
nvim_lua_dir="$HOME/.config/nvim/lua"
|
||||
module1="tmux_split_even_horizontal.lua"
|
||||
module2="toggle_rel_abs_numbers.lua"
|
||||
|
||||
# Function to check if a file exists
|
||||
check_file() {
|
||||
if [[ -f "$1" ]]; then
|
||||
echo "File exists: $1"
|
||||
else
|
||||
echo "File NOT found: $1"
|
||||
fi
|
||||
}
|
||||
|
||||
echo "Checking Lua modules..."
|
||||
|
||||
# Check Lua modules
|
||||
check_file "$nvim_lua_dir/$module1"
|
||||
check_file "$nvim_lua_dir/$module2"
|
||||
|
||||
# Check LUA_PATH
|
||||
echo "Checking LUA_PATH..."
|
||||
echo "LUA_PATH=$LUA_PATH"
|
||||
|
||||
# Check Lua module loading
|
||||
echo "Attempting to manually load Lua modules..."
|
||||
lua -e "require('tmux_split_even_horizontal'); print('Module tmux_split_even_horizontal loaded successfully')"
|
||||
lua -e "require('toggle_rel_abs_numbers'); print('Module toggle_rel_abs_numbers loaded successfully')"
|
||||
|
||||
echo "Diagnostic checks complete."
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local coq = require "coq"
|
||||
coq.Now() -- Start coq
|
||||
|
||||
-- 3party sources
|
||||
require "coq_3p" {
|
||||
{ src = "nvimlua", short_name = "nLUA", conf_only = false }, -- Lua
|
||||
{ src = "bc", short_name = "MATH", precision = 6 }, -- Calculator
|
||||
{ src = "cow", trigger = "!cow" }, -- cow command
|
||||
{ src = "figlet", trigger = "!big" }, -- figlet command
|
||||
{
|
||||
src = "repl",
|
||||
sh = "zsh",
|
||||
shell = { p = "perl", n = "node" },
|
||||
max_lines = 99,
|
||||
deadline = 500,
|
||||
unsafe = { "rm", "poweroff", "mv" },
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
|
@ -0,0 +1,7 @@
|
|||
vim.g.mapleader = " "
|
||||
--mapleader = vim.g.mapleader
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
vim.keymap.set("n", "<Leader>E", vim.cmd.Ex)
|
||||
-- vim.keymap.set('n', "<Leader>to", function() require('telescope.builtin').oldfiles() end)
|
||||
vim.keymap.set('n', "<Leader>to", builtin.oldfiles, {})
|
|
@ -0,0 +1,174 @@
|
|||
local inspect = require('inspect')
|
||||
require('ldraneyLua/sudoCheckSave')
|
||||
require('hotkeys')
|
||||
require('netrw/netrw')
|
||||
|
||||
--Global options
|
||||
vim.opt.list = true
|
||||
--vim.opt.listchars:append("space:⋅")
|
||||
vim.opt.listchars:append("eol:↴")
|
||||
|
||||
--require("indent_blankline").setup {
|
||||
--show_end_of_line = true,
|
||||
--space_char_blankline = " ",
|
||||
--}
|
||||
|
||||
--turn off automatic comments for newlines with o
|
||||
--https://www.reddit.com/r/neovim/comments/sqld76/stop_automatic_newline_continuation_of_comments/
|
||||
vim.cmd("autocmd BufEnter * set formatoptions-=cro")
|
||||
vim.cmd("autocmd BufEnter * setlocal formatoptions-=cro")
|
||||
|
||||
--local function tmux_split_even_horizontal()
|
||||
--local filepath = vim.fn.expand('%:p')
|
||||
--if filepath ~= '' then
|
||||
--local tmux_command = "tmux split-window -h -c '" .. vim.fn.expand('%:p:h') .. "' && tmux send-keys -t '.tmux.active-pane' 'nvim " .. vim.fn.shellescape(filepath) .. "' Enter && tmux select-layout even-horizontal"
|
||||
--vim.fn.system(tmux_command)
|
||||
--end
|
||||
--end
|
||||
|
||||
--vim.api.nvim_set_keymap('n', '<leader>th', ':lua tmux_split_even_horizontal()<CR>', { noremap = true, silent = true })
|
||||
|
||||
|
||||
--_G.tmux_split_even_horizontal = function()
|
||||
--local filepath = vim.fn.expand('%:p')
|
||||
--if filepath ~= '' then
|
||||
--local tmux_command = "tmux split-window -h -c '" .. vim.fn.expand('%:p:h') .. "' && tmux send-keys -t '.tmux.active-pane' 'nvim " .. vim.fn.shellescape(filepath) .. "' Enter && tmux select-layout even-horizontal"
|
||||
--vim.fn.system(tmux_command)
|
||||
--end
|
||||
--end
|
||||
|
||||
--_G.tmux_split_even_horizontal = function()
|
||||
--local filepath = vim.fn.expand('%:p')
|
||||
--if filepath ~= '' then
|
||||
--local tmux_command = "tmux split-window -h 'nvim'"
|
||||
--vim.fn.system(tmux_command)
|
||||
----print("Pane ID: " .. tmux_pane_id)
|
||||
--print("Filepath: " .. filepath)
|
||||
--end
|
||||
--end
|
||||
|
||||
_G.tmux_split_even_horizontal = function()
|
||||
local filepath = vim.fn.expand('%:p')
|
||||
if filepath ~= '' then
|
||||
local tmux_command = "tmux split-window -h 'nvim -n " .. filepath .. "'; select-layout even-horizontal"
|
||||
vim.fn.system(tmux_command)
|
||||
print("Filepath: " .. filepath)
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_set_keymap('n', '<leader>th', ':lua _G.tmux_split_even_horizontal()<CR>', { noremap = true, silent = true })
|
||||
|
||||
|
||||
|
||||
--
|
||||
--
|
||||
--
|
||||
--require('lspconfig').pyright.setup{}
|
||||
--require('lspconfig').bashls.setup{}
|
||||
--require'lspconfig'.pylsp.setup{}
|
||||
---- Mappings.
|
||||
---- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
||||
--local opts = { noremap=true, silent=true }
|
||||
--vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||
--vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||
--vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||
--vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
|
||||
|
||||
---- Use an on_attach function to only map the following keys
|
||||
---- after the language server attaches to the current buffer
|
||||
--local on_attach = function(client, bufnr)
|
||||
---- Enable completion triggered by <c-x><c-o>
|
||||
--vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||
|
||||
---- Mappings.
|
||||
---- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||
--vim.api.nvim_set_keymap("n", "<leader>rn", "<cmd>lua vim.lsp.buf.rename()<CR>", { noremap = true })
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
||||
--vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
||||
--end
|
||||
|
||||
---- Use a loop to conveniently call 'setup' on multiple servers and
|
||||
---- map buffer local keybindings when the language server attaches
|
||||
--local servers = { 'pyright', 'rust_analyzer', 'tsserver' }
|
||||
--for _, lsp in pairs(servers) do
|
||||
--require('lspconfig')[lsp].setup {
|
||||
--on_attach = on_attach,
|
||||
--flags = {
|
||||
---- This will be the default in neovim 0.7+
|
||||
--debounce_text_changes = 150,
|
||||
--}
|
||||
--}
|
||||
--end
|
||||
---- Add additional capabilities supported by nvim-cmp
|
||||
--local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
--capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)
|
||||
|
||||
--local lspconfig = require('lspconfig')
|
||||
|
||||
---- Enable some language servers with the additional completion capabilities offered by nvim-cmp
|
||||
--local servers = { 'clangd', 'rust_analyzer', 'pyright', 'tsserver' }
|
||||
--for _, lsp in ipairs(servers) do
|
||||
--lspconfig[lsp].setup {
|
||||
---- on_attach = my_custom_on_attach,
|
||||
--capabilities = capabilities,
|
||||
--}
|
||||
--end
|
||||
|
||||
---- luasnip setup
|
||||
--local luasnip = require 'luasnip'
|
||||
|
||||
---- nvim-cmp setup
|
||||
--local cmp = require 'cmp'
|
||||
--cmp.setup {
|
||||
--snippet = {
|
||||
--expand = function(args)
|
||||
--require('luasnip').lsp_expand(args.body)
|
||||
--end,
|
||||
--},
|
||||
--mapping = {
|
||||
--['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||
--['<C-n>'] = cmp.mapping.select_next_item(),
|
||||
--['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
--['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
--['<C-Space>'] = cmp.mapping.complete(),
|
||||
--['<C-e>'] = cmp.mapping.close(),
|
||||
--['<CR>'] = cmp.mapping.confirm {
|
||||
--behavior = cmp.ConfirmBehavior.Replace,
|
||||
--select = true,
|
||||
--},
|
||||
--['<Tab>'] = function(fallback)
|
||||
--if cmp.visible() then
|
||||
--cmp.select_next_item()
|
||||
--elseif luasnip.expand_or_jumpable() then
|
||||
--luasnip.expand_or_jump()
|
||||
--else
|
||||
--fallback()
|
||||
--end
|
||||
--end,
|
||||
--['<S-Tab>'] = function(fallback)
|
||||
--if cmp.visible() then
|
||||
--cmp.select_prev_item()
|
||||
--elseif luasnip.jumpable(-1) then
|
||||
--luasnip.jump(-1)
|
||||
--else
|
||||
--fallback()
|
||||
--end
|
||||
--end,
|
||||
--},
|
||||
--sources = {
|
||||
--{ name = 'nvim_lsp' },
|
||||
--{ name = 'luasnip' },
|
||||
--},
|
||||
--}
|
||||
|
|
@ -0,0 +1,337 @@
|
|||
local _tl_compat; if (tonumber((_VERSION or ''):match('[%d.]*$')) or 0) < 5.3 then local p, m = pcall(require, 'compat53.module'); if p then _tl_compat = m end end; local math = _tl_compat and _tl_compat.math or math; local string = _tl_compat and _tl_compat.string or string; local table = _tl_compat and _tl_compat.table or table
|
||||
local inspect = {Options = {}, }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
inspect._VERSION = 'inspect.lua 3.1.0'
|
||||
inspect._URL = 'http://github.com/kikito/inspect.lua'
|
||||
inspect._DESCRIPTION = 'human-readable representations of tables'
|
||||
inspect._LICENSE = [[
|
||||
MIT LICENSE
|
||||
|
||||
Copyright (c) 2022 Enrique García Cota
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
]]
|
||||
inspect.KEY = setmetatable({}, { __tostring = function() return 'inspect.KEY' end })
|
||||
inspect.METATABLE = setmetatable({}, { __tostring = function() return 'inspect.METATABLE' end })
|
||||
|
||||
local tostring = tostring
|
||||
local rep = string.rep
|
||||
local match = string.match
|
||||
local char = string.char
|
||||
local gsub = string.gsub
|
||||
local fmt = string.format
|
||||
|
||||
local function rawpairs(t)
|
||||
return next, t, nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
local function smartQuote(str)
|
||||
if match(str, '"') and not match(str, "'") then
|
||||
return "'" .. str .. "'"
|
||||
end
|
||||
return '"' .. gsub(str, '"', '\\"') .. '"'
|
||||
end
|
||||
|
||||
|
||||
local shortControlCharEscapes = {
|
||||
["\a"] = "\\a", ["\b"] = "\\b", ["\f"] = "\\f", ["\n"] = "\\n",
|
||||
["\r"] = "\\r", ["\t"] = "\\t", ["\v"] = "\\v", ["\127"] = "\\127",
|
||||
}
|
||||
local longControlCharEscapes = { ["\127"] = "\127" }
|
||||
for i = 0, 31 do
|
||||
local ch = char(i)
|
||||
if not shortControlCharEscapes[ch] then
|
||||
shortControlCharEscapes[ch] = "\\" .. i
|
||||
longControlCharEscapes[ch] = fmt("\\%03d", i)
|
||||
end
|
||||
end
|
||||
|
||||
local function escape(str)
|
||||
return (gsub(gsub(gsub(str, "\\", "\\\\"),
|
||||
"(%c)%f[0-9]", longControlCharEscapes),
|
||||
"%c", shortControlCharEscapes))
|
||||
end
|
||||
|
||||
local function isIdentifier(str)
|
||||
return type(str) == "string" and not not str:match("^[_%a][_%a%d]*$")
|
||||
end
|
||||
|
||||
local flr = math.floor
|
||||
local function isSequenceKey(k, sequenceLength)
|
||||
return type(k) == "number" and
|
||||
flr(k) == k and
|
||||
1 <= (k) and
|
||||
k <= sequenceLength
|
||||
end
|
||||
|
||||
local defaultTypeOrders = {
|
||||
['number'] = 1, ['boolean'] = 2, ['string'] = 3, ['table'] = 4,
|
||||
['function'] = 5, ['userdata'] = 6, ['thread'] = 7,
|
||||
}
|
||||
|
||||
local function sortKeys(a, b)
|
||||
local ta, tb = type(a), type(b)
|
||||
|
||||
|
||||
if ta == tb and (ta == 'string' or ta == 'number') then
|
||||
return (a) < (b)
|
||||
end
|
||||
|
||||
local dta = defaultTypeOrders[ta] or 100
|
||||
local dtb = defaultTypeOrders[tb] or 100
|
||||
|
||||
|
||||
return dta == dtb and ta < tb or dta < dtb
|
||||
end
|
||||
|
||||
local function getKeys(t)
|
||||
|
||||
local seqLen = 1
|
||||
while rawget(t, seqLen) ~= nil do
|
||||
seqLen = seqLen + 1
|
||||
end
|
||||
seqLen = seqLen - 1
|
||||
|
||||
local keys, keysLen = {}, 0
|
||||
for k in rawpairs(t) do
|
||||
if not isSequenceKey(k, seqLen) then
|
||||
keysLen = keysLen + 1
|
||||
keys[keysLen] = k
|
||||
end
|
||||
end
|
||||
table.sort(keys, sortKeys)
|
||||
return keys, keysLen, seqLen
|
||||
end
|
||||
|
||||
local function countCycles(x, cycles)
|
||||
if type(x) == "table" then
|
||||
if cycles[x] then
|
||||
cycles[x] = cycles[x] + 1
|
||||
else
|
||||
cycles[x] = 1
|
||||
for k, v in rawpairs(x) do
|
||||
countCycles(k, cycles)
|
||||
countCycles(v, cycles)
|
||||
end
|
||||
countCycles(getmetatable(x), cycles)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function makePath(path, a, b)
|
||||
local newPath = {}
|
||||
local len = #path
|
||||
for i = 1, len do newPath[i] = path[i] end
|
||||
|
||||
newPath[len + 1] = a
|
||||
newPath[len + 2] = b
|
||||
|
||||
return newPath
|
||||
end
|
||||
|
||||
|
||||
local function processRecursive(process,
|
||||
item,
|
||||
path,
|
||||
visited)
|
||||
if item == nil then return nil end
|
||||
if visited[item] then return visited[item] end
|
||||
|
||||
local processed = process(item, path)
|
||||
if type(processed) == "table" then
|
||||
local processedCopy = {}
|
||||
visited[item] = processedCopy
|
||||
local processedKey
|
||||
|
||||
for k, v in rawpairs(processed) do
|
||||
processedKey = processRecursive(process, k, makePath(path, k, inspect.KEY), visited)
|
||||
if processedKey ~= nil then
|
||||
processedCopy[processedKey] = processRecursive(process, v, makePath(path, processedKey), visited)
|
||||
end
|
||||
end
|
||||
|
||||
local mt = processRecursive(process, getmetatable(processed), makePath(path, inspect.METATABLE), visited)
|
||||
if type(mt) ~= 'table' then mt = nil end
|
||||
setmetatable(processedCopy, mt)
|
||||
processed = processedCopy
|
||||
end
|
||||
return processed
|
||||
end
|
||||
|
||||
local function puts(buf, str)
|
||||
buf.n = buf.n + 1
|
||||
buf[buf.n] = str
|
||||
end
|
||||
|
||||
|
||||
|
||||
local Inspector = {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
local Inspector_mt = { __index = Inspector }
|
||||
|
||||
local function tabify(inspector)
|
||||
puts(inspector.buf, inspector.newline .. rep(inspector.indent, inspector.level))
|
||||
end
|
||||
|
||||
function Inspector:getId(v)
|
||||
local id = self.ids[v]
|
||||
local ids = self.ids
|
||||
if not id then
|
||||
local tv = type(v)
|
||||
id = (ids[tv] or 0) + 1
|
||||
ids[v], ids[tv] = id, id
|
||||
end
|
||||
return tostring(id)
|
||||
end
|
||||
|
||||
function Inspector:putValue(v)
|
||||
local buf = self.buf
|
||||
local tv = type(v)
|
||||
if tv == 'string' then
|
||||
puts(buf, smartQuote(escape(v)))
|
||||
elseif tv == 'number' or tv == 'boolean' or tv == 'nil' or
|
||||
tv == 'cdata' or tv == 'ctype' then
|
||||
puts(buf, tostring(v))
|
||||
elseif tv == 'table' and not self.ids[v] then
|
||||
local t = v
|
||||
|
||||
if t == inspect.KEY or t == inspect.METATABLE then
|
||||
puts(buf, tostring(t))
|
||||
elseif self.level >= self.depth then
|
||||
puts(buf, '{...}')
|
||||
else
|
||||
if self.cycles[t] > 1 then puts(buf, fmt('<%d>', self:getId(t))) end
|
||||
|
||||
local keys, keysLen, seqLen = getKeys(t)
|
||||
|
||||
puts(buf, '{')
|
||||
self.level = self.level + 1
|
||||
|
||||
for i = 1, seqLen + keysLen do
|
||||
if i > 1 then puts(buf, ',') end
|
||||
if i <= seqLen then
|
||||
puts(buf, ' ')
|
||||
self:putValue(t[i])
|
||||
else
|
||||
local k = keys[i - seqLen]
|
||||
tabify(self)
|
||||
if isIdentifier(k) then
|
||||
puts(buf, k)
|
||||
else
|
||||
puts(buf, "[")
|
||||
self:putValue(k)
|
||||
puts(buf, "]")
|
||||
end
|
||||
puts(buf, ' = ')
|
||||
self:putValue(t[k])
|
||||
end
|
||||
end
|
||||
|
||||
local mt = getmetatable(t)
|
||||
if type(mt) == 'table' then
|
||||
if seqLen + keysLen > 0 then puts(buf, ',') end
|
||||
tabify(self)
|
||||
puts(buf, '<metatable> = ')
|
||||
self:putValue(mt)
|
||||
end
|
||||
|
||||
self.level = self.level - 1
|
||||
|
||||
if keysLen > 0 or type(mt) == 'table' then
|
||||
tabify(self)
|
||||
elseif seqLen > 0 then
|
||||
puts(buf, ' ')
|
||||
end
|
||||
|
||||
puts(buf, '}')
|
||||
end
|
||||
|
||||
else
|
||||
puts(buf, fmt('<%s %d>', tv, self:getId(v)))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
function inspect.inspect(root, options)
|
||||
options = options or {}
|
||||
|
||||
local depth = options.depth or (math.huge)
|
||||
local newline = options.newline or '\n'
|
||||
local indent = options.indent or ' '
|
||||
local process = options.process
|
||||
|
||||
if process then
|
||||
root = processRecursive(process, root, {}, {})
|
||||
end
|
||||
|
||||
local cycles = {}
|
||||
countCycles(root, cycles)
|
||||
|
||||
local inspector = setmetatable({
|
||||
buf = { n = 0 },
|
||||
ids = {},
|
||||
cycles = cycles,
|
||||
depth = depth,
|
||||
level = 0,
|
||||
newline = newline,
|
||||
indent = indent,
|
||||
}, Inspector_mt)
|
||||
|
||||
inspector:putValue(root)
|
||||
|
||||
return table.concat(inspector.buf)
|
||||
end
|
||||
|
||||
setmetatable(inspect, {
|
||||
__call = function(_, root, options)
|
||||
return inspect.inspect(root, options)
|
||||
end,
|
||||
})
|
||||
|
||||
return inspect
|
|
@ -0,0 +1,21 @@
|
|||
-- **DEPRECATED**
|
||||
-- I had to do a bash script isntead, since the sudo thing didn't work
|
||||
--
|
||||
--
|
||||
--This function is useful so that I don't accidentally forget to use
|
||||
--"sudoedit" when editing VMShare.
|
||||
|
||||
--fullFilePath = vim.api.nvim_buf_get_name(0)
|
||||
---- check if filePath is VMShare. If it is, then force the save
|
||||
--function saveSudoCheck()
|
||||
--if (string.find(fullFilePath, "hgfs")) then
|
||||
--vim.cmd [[w !echo 'Asdfjkl7&' | sudo -S tee % >/dev/null]]
|
||||
--else
|
||||
--print("bye mom")
|
||||
--vim.cmd [[w]]
|
||||
--end
|
||||
--end
|
||||
|
||||
----set the keymap to s
|
||||
--local opts = { noremap=true, silent=true }
|
||||
--vim.api.nvim_set_keymap('n', '<C-s>', "<cmd>lua saveSudoCheck()<CR>", opts)
|
|
@ -0,0 +1,47 @@
|
|||
|
||||
--The following code defines a function called ExitNetrw(), that checks if the current filetype is "netrw" (i.e. if you are currently in netrw), and if so, it changes the current working directory of the terminal to the directory of the current file or directory you are looking at in netrw, and then exits Neovim. If the current filetype is not "netrw", it will simply exit Neovim.
|
||||
|
||||
--It also maps the <C-q> key to call this function, so when you press <C-q> it will change the working directory and exit netrw, but if you're not in netrw it will exit Neovim directly.
|
||||
|
||||
--You can change the keybinding to your preferred key, just replace <C-q> with your preferred key.
|
||||
|
||||
local nvim_command = vim.api.nvim_command
|
||||
local nvim_call_function = vim.api.nvim_call_function
|
||||
|
||||
function ExitNetrw()
|
||||
if vim.bo.filetype == "netrw" then
|
||||
cwd = nvim_call_function("expand", {"%:p:h"})
|
||||
nvim_command("!cd " .. cwd)
|
||||
nvim_command("qa!")
|
||||
else
|
||||
nvim_command("qa!")
|
||||
end
|
||||
end
|
||||
-- need to remap this at some point
|
||||
--vim.cmd("nnoremap <silent> <C-q> :lua ExitNetrw()<CR>")
|
||||
|
||||
|
||||
|
||||
--exit neovim to the $NVIM_PWD
|
||||
--local nvim_set_option = vim.api.nvim_set_option
|
||||
--local os_getenv = os.getenv
|
||||
--
|
||||
|
||||
local os = require('os')
|
||||
local os_execute = os.execute
|
||||
local os_getenv = os.getenv
|
||||
|
||||
local pwd = os.getenv('PWD')
|
||||
--print(pwd)
|
||||
|
||||
--
|
||||
--
|
||||
--os_execute = vim.loop.os_execute
|
||||
--os_getenv = vim.loop.os_getenv
|
||||
|
||||
--vim.cmd("autocmd BufLeave * lua os_execute(\"cd \".. os_getenv(\"NVIM_PWD\"))")
|
||||
--local os = require('os')
|
||||
--local os_execute = os.execute
|
||||
--local os_getenv = os.getenv
|
||||
|
||||
--vim.cmd("autocmd BufLeave * lua os_execute("cd ".. os_getenv("NVIM_PWD"))")
|
|
@ -0,0 +1,15 @@
|
|||
use {
|
||||
"ms-jpq/coq_nvim",
|
||||
branch = "coq",
|
||||
event = "InsertEnter",
|
||||
opt = true,
|
||||
run = ":COQdeps",
|
||||
config = function()
|
||||
require("config.coq").setup()
|
||||
end,
|
||||
requires = {
|
||||
{ "ms-jpq/coq.artifacts", branch = "artifacts" },
|
||||
{ "ms-jpq/coq.thirdparty", branch = "3p", module = "coq_3p" },
|
||||
},
|
||||
disable = false,
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
-- Mock setup
|
||||
_G.vim = {
|
||||
wo = {}, -- Window-scoped options
|
||||
bo = {}, -- Buffer-scoped options
|
||||
-- Add more fields as needed
|
||||
}
|
||||
|
||||
-- Example usage in a test case
|
||||
describe("My Neovim Function", function()
|
||||
it("does something", function()
|
||||
-- Test code that uses the mock `vim` object
|
||||
end)
|
||||
end)
|
||||
|
||||
local tmux_split_even_horizontal = require('tmux_split_even_horizontal')
|
||||
|
||||
describe("tmux_split_even_horizontal", function()
|
||||
local tmux_split_even_horizontal = require('tmux_split_even_horizontal')
|
||||
|
||||
it("should not throw errors", function()
|
||||
assert.has_no.errors(function()
|
||||
tmux_split_even_horizontal.tmux_split_even_horizontal()
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Additional tests can be added here
|
||||
end)
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
-- Mock setup
|
||||
_G.vim = {
|
||||
wo = {}, -- Window-scoped options
|
||||
bo = {}, -- Buffer-scoped options
|
||||
-- Add more fields as needed
|
||||
}
|
||||
|
||||
-- Example usage in a test case
|
||||
describe("My Neovim Function", function()
|
||||
it("does something", function()
|
||||
-- Test code that uses the mock `vim` object
|
||||
end)
|
||||
end)
|
||||
|
||||
describe("toggle_line_numbers", function()
|
||||
local toggle_line_numbers
|
||||
|
||||
-- Mock setup before each test
|
||||
before_each(function()
|
||||
_G.vim = { wo = { relativenumber = false, number = false } }
|
||||
package.loaded['toggle_rel_abs_numbers'] = nil -- Unload the module
|
||||
toggle_line_numbers = require('toggle_rel_abs_numbers').toggle_line_numbers
|
||||
end)
|
||||
|
||||
it("toggles from relative to absolute line numbers", function()
|
||||
toggle_line_numbers()
|
||||
assert.is_true(vim.wo.relativenumber)
|
||||
assert.is_true(vim.wo.number)
|
||||
|
||||
toggle_line_numbers()
|
||||
assert.is_false(vim.wo.relativenumber)
|
||||
assert.is_true(vim.wo.number)
|
||||
end)
|
||||
end)
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
local M = {}
|
||||
|
||||
function M.tmux_split_even_horizontal()
|
||||
local status, err = pcall(function()
|
||||
local filepath = vim.fn.expand('%:p')
|
||||
if filepath ~= '' then
|
||||
local tmux_command = "tmux split-window -h -c '" .. vim.fn.expand('%:p:h') ..
|
||||
"' && tmux send-keys -t '.tmux.active-pane' 'nvim " ..
|
||||
vim.fn.shellescape(filepath) .. "' Enter && tmux select-layout even-horizontal"
|
||||
vim.fn.system(tmux_command)
|
||||
end
|
||||
end)
|
||||
if not status then
|
||||
print("Error in tmux_split_even_horizontal: " .. err)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
local M = {} -- Create a local table M to hold the module's functions
|
||||
|
||||
-- Function to toggle line numbers between relative and absolute
|
||||
function M.toggle_line_numbers()
|
||||
local status, err = pcall(function()
|
||||
-- Use pcall to catch any errors in the following block
|
||||
if vim.wo.relativenumber then
|
||||
-- If relative line numbers are on, turn them off and ensure absolute numbers are on
|
||||
vim.wo.relativenumber = false
|
||||
vim.wo.number = true
|
||||
else
|
||||
-- If relative line numbers are off, turn them on (absolute numbers stay on)
|
||||
vim.wo.relativenumber = true
|
||||
vim.wo.number = true
|
||||
end
|
||||
end)
|
||||
if not status then
|
||||
-- If there was an error, print it
|
||||
print("Error in toggle_line_numbers: " .. err)
|
||||
end
|
||||
end
|
||||
|
||||
return M -- Return the table containing the module's functions
|
|
@ -0,0 +1,8 @@
|
|||
--local nvim_command = vim.api.nvim_command
|
||||
|
||||
--function OpenHelpInVerticalSplit()
|
||||
--local input = vim.fn.input("Search term: ")
|
||||
--nvim_command("vert h " .. input)
|
||||
--end
|
||||
|
||||
--vim.cmd("nnoremap <leader>h :lua OpenHelpInVerticalSplit()<CR>")
|
Loading…
Reference in New Issue