summaryrefslogtreecommitdiff
path: root/files/nvim
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-01-01 17:39:28 -0500
committerAndrew Opalach <andrew@akon.city> 2025-01-01 17:39:28 -0500
commit4849fc6e811f9aaa02a63d102f60d356365cd2bb (patch)
treea45fdd1065b1b6052283e257e19123696b548671 /files/nvim
parent8ed2c4a005c634e9d4a2aa5e31f40901def3adda (diff)
downloaddotfiles-4849fc6e811f9aaa02a63d102f60d356365cd2bb.tar.gz
dotfiles-4849fc6e811f9aaa02a63d102f60d356365cd2bb.tar.bz2
dotfiles-4849fc6e811f9aaa02a63d102f60d356365cd2bb.zip
Theme stuff
Diffstat (limited to 'files/nvim')
-rw-r--r--files/nvim/init.vim74
1 files changed, 47 insertions, 27 deletions
diff --git a/files/nvim/init.vim b/files/nvim/init.vim
index 70ba94d..aa6cd7d 100644
--- a/files/nvim/init.vim
+++ b/files/nvim/init.vim
@@ -6,7 +6,12 @@ set updatetime=250
set scrolloff=5
" Change directory based on current file.
-set autochdir
+if !empty($NIX_SHELL)
+ " Attempt to conflict less with plugins.
+ autocmd BufEnter * if gitbranch#name() != '' | silent! lcd %:p:h
+else
+ set autochdir
+endif
" inotify compat?
set backupcopy=yes
@@ -28,7 +33,7 @@ set autoindent
" C syntax preference.
let g:c_syntax_for_h=1
-set cinoptions=l1,:0,g2,h2,(4,u0
+set cinoptions=:0,=4,l1,g2,h2,(4,u4,+4,m1
set cindent
" Set different format for mail and text files.
@@ -56,16 +61,6 @@ if !isdirectory(view_dir)
call mkdir(view_dir, "p", 0700)
endif
let &viewdir=view_dir
-" https://github.com/zhimsel/vim-stay/issues/10#issuecomment-336637546
-augroup stay_no_lcd
- autocmd!
- if exists(':tcd') == 2
- autocmd User BufStaySavePre if haslocaldir() | let w:lcd = getcwd() | exe 'cd '.fnameescape(getcwd(-1, -1)) | endif
- else
- autocmd User BufStaySavePre if haslocaldir() | let w:lcd = getcwd() | cd - | cd - | endif
- endif
- autocmd User BufStaySavePost if exists('w:lcd') | execute 'lcd' fnameescape(w:lcd) | unlet w:lcd | endif
-augroup END
" Staggered backups.
if isdirectory(expand('/mnt/store/backup/vim'))
@@ -88,7 +83,6 @@ if has("persistent_undo")
endif
" Colorscheme.
-set background=dark
set termguicolors
colo wal-gui
@@ -111,17 +105,25 @@ let g:fzf_colors = {
\'info': ['fg', 'PreProc'],
\'border': ['fg', 'Operator'],
\'prompt': ['fg', 'Identifier'],
- \'pointer': ['fg', 'String'],
+ \'pointer': ['fg', 'Type'],
\'marker': ['fg', 'Keyword'],
\'spinner': ['fg', 'String'],
\'header': ['fg', 'Type']
\}
let g:fzf_preview_window = ['right,47%']
-let g:fzf_layout = { 'window': { 'width': 0.65, 'height': 0.50 } }
+let g:fzf_layout = { 'window': { 'width': 0.70, 'height': 0.50 } }
+
+function! StatuslineMode() abort
+ if mode() == nr2char(22)
+ return mode()
+ else
+ return '-'.mode()
+ endif
+endfunction
function! StatuslineGit()
let l:branchname = gitbranch#name()
- return strlen(l:branchname) > 0?' '.l:branchname.' ':''
+ return strlen(l:branchname) > 0 ? ' '.l:branchname.' ' : ' '
endfunction
lua << EOF
@@ -142,10 +144,9 @@ endfunction
" Custom statusline.
function! Statusline() abort
let focused = g:statusline_winid == win_getid(winnr())
- let status = (focused ? '%#StatusLine#' : '%#StatusLineNC#')
+ let status = focused ? '%#StatusLine#' : '%#StatusLineNC#'
let status .= '%{StatuslineGit()}'
let status .= ' %f'
- let status .= ' %m'
let status .= ' vim@%{hostname()}'
let status .= '%='
let status .= ' %y'
@@ -174,6 +175,13 @@ if os.getenv('NIX_SHELL') ~= nil then
'--pch-storage=memory',
'--header-insertion=never',
'--header-insertion-decorators=0'
+ },
+ capabilities = {
+ textDocument = {
+ semanticHighlightingCapabilities = {
+ semanticHighlighting = true
+ }
+ }
}
})
lsp.ruff.setup({})
@@ -247,31 +255,43 @@ vim.keymap.set('n', '<C-k>', [[:wincmd k<CR>]], { silent = true })
vim.keymap.set('n', '<C-l>', [[:wincmd l<CR>]], { silent = true })
vim.keymap.set('n', '<C-o>', [[:vsplit<CR>]], { silent = true })
-- Make ctrl + '.' and ',' map to previous buffer.
-vim.keymap.set('n', '<C-,>', '<c-^>', {})
-vim.keymap.set('n', '<C-.>', '<c-^>', {})
+vim.keymap.set('n', '<C-,>', '<C-^>', {})
+vim.keymap.set('n', '<C-.>', '<C-^>', {})
+-- Swap ctrl + f and b.
+vim.keymap.set('n', '<C-f>', '<C-b>', {})
+vim.keymap.set('n', '<C-b>', '<C-f>', {})
-- Undotree
vim.keymap.set('n', 'U', vim.cmd.UndotreeToggle)
-- Toggle colorcolumn.
vim.keymap.set('n', 'C', [[:execute 'set colorcolumn=' . (&colorcolumn == '' ? '101' : '')<CR>]], { silent = true })
+-- Personally intuitive pop-up menu binds.
+vim.keymap.set('i', '<CR>', [[pumvisible() ? '<C-y><CR>' : '<CR>']], { expr = true })
+vim.keymap.set('i', '<Up>', [[pumvisible() ? '<C-p>' : '<Up>']], { expr = true })
+vim.keymap.set('i', '<Down>', [[pumvisible() ? '<C-n>' : '<Down>']], { expr = true })
-- Lsp Binds.
vim.keymap.set('n', '<C-d>', '<C-]>', {})
vim.keymap.set('n', '<C-n>', function()
return ":IncRename " .. vim.fn.expand("<cword>")
end, { expr = true })
-- Fzf binds.
-vim.keymap.set('n', '<C-i>', [[:GGrep<CR>]], { silent = true })
vim.keymap.set('n', '\\', [[:Buffers<CR>]], { silent = true })
--- Personally intuitive pop-up menu binds.
-vim.keymap.set('i', '<CR>', [[pumvisible() ? '<C-y><CR>' : '<CR>']], { expr = true })
-vim.keymap.set('i', '<Up>', [[pumvisible() ? '<C-p>' : '<Up>']], { expr = true })
-vim.keymap.set('i', '<Down>', [[pumvisible() ? '<C-n>' : '<Down>']], { expr = true })
--- Only Neogit bind, handle all further operations from this menu.
-vim.keymap.set('n', 'Y', [[:Neogit<CR>]], { silent = true })
+if os.getenv('NIX_SHELL') ~= nil then
+ vim.keymap.set('n', '<C-i>', [[:GGrep<CR>]], { silent = true })
+ vim.keymap.set('n', '<C-\\>', [[:GFiles<CR>]], { silent = true })
+ -- Only Neogit bind, handle all further operations from this menu.
+ vim.keymap.set('n', 'Y', [[:Neogit<CR>]], { silent = true })
+end
EOF
command Tabify set noexpandtab | %retab! | set expandtab
command Untabify set expandtab | %retab!
+" https://stackoverflow.com/a/37040415
+function! SyntaxGroup()
+ let l:s = synID(line('.'), col('.'), 1)
+ echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
+endfun
+
" https://github.com/junegunn/fzf.vim?tab=readme-ov-file#example-git-grep-wrapper
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(