Skip to content

Commit

Permalink
feat(vim): what an adventure
Browse files Browse the repository at this point in the history
  • Loading branch information
vEnhance committed Dec 24, 2024
1 parent 41dc7d3 commit f639c1b
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .codespellrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[codespell]
skip=vim/autoload/plug.vim,i3/3kon/*,i18n/zh_TW/LC_MESSAGES/*,ranger/*,vim/after/ftplugin/asy.vim,sh-scripts/git-prompt.bash,sh-scripts/git-completion.bash,gh-extensions/*,lualatex-font-catalog/*,*/poetry.lock,texmf/tex/latex/beamer/*,typst/packages/local/svg-emoji/*,nvim/lazy-lock.json
skip=vim/autoload/plug.vim,i3/3kon/*,i18n/zh_TW/LC_MESSAGES/*,ranger/*,vim/after/ftplugin/asy.vim,sh-scripts/git-prompt.bash,sh-scripts/git-completion.bash,gh-extensions/*,lualatex-font-catalog/*,*/poetry.lock,texmf/tex/latex/beamer/*,typst/packages/local/svg-emoji/*
count=
ignore-words-list=ques,alph,mor,nd,progamer,iterm,oly,scaleable,ake,Fallin,WarpIn,ABD,Hom,forin,oint
ignore-words-list=ques,alph,mor,nd,progamer,iterm,oly,scaleable,ake,Fallin,WarpIn,ABD,Hom,forin,oint,noice
83 changes: 68 additions & 15 deletions nvim/lua/config/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,23 @@ vim.keymap.set("n", "<CR>", function()
else
return "<CR>"
end
end, { expr = true, noremap = true, desc = "Write all" })
end, { expr = true, remap = true, desc = "Write all" })

vim.keymap.del("n", "s")
vim.keymap.del("n", "S")

vim.keymap.set(
"n",
"<Space>e",
":let $VIM_DIR=expand('%:p:h')<CR>:silent !xfce4-terminal --working-directory='$VIM_DIR' &<CR>",
{ noremap = true, desc = "Open an xfce4-terminal" }
)
vim.keymap.set("n", "<Space>t", function()
vim.cmd("silent !xfce4-terminal --working-directory='" .. vim.fn.expand("%:p:h") .. "' &")
end, { noremap = true, silent = true, desc = "Open an xfce4-terminal" })

vim.keymap.set("n", "-h", "<C-w>h", { noremap = true, desc = "Move one window left" })
vim.keymap.set("n", "-l", "<C-w>l", { noremap = true, desc = "Move one window right" })
vim.keymap.set("n", "-j", "<C-w>j", { noremap = true, desc = "Move one window down" })
vim.keymap.set("n", "-k", "<C-w>k", { noremap = true, desc = "Move one window up" })
vim.keymap.set("n", "-i", ":split<CR>", { noremap = true, desc = "Open a horizontal split" })
vim.keymap.set("n", "-s", ":vsplit<CR>", { noremap = true, desc = "Open a vertical split" })

vim.keymap.set("n", "<BS>", ":bp<CR>", { noremap = true, desc = "Previous buffer" })
vim.keymap.set("n", "-o", "<C-w>o", { noremap = true, silent = true, desc = "Maximize window" })
vim.keymap.set("n", "-h", "<C-w>h", { noremap = true, silent = true, desc = "Move one window left" })
vim.keymap.set("n", "-l", "<C-w>l", { noremap = true, silent = true, desc = "Move one window right" })
vim.keymap.set("n", "-j", "<C-w>j", { noremap = true, silent = true, desc = "Move one window down" })
vim.keymap.set("n", "-k", "<C-w>k", { noremap = true, silent = true, desc = "Move one window up" })
vim.keymap.set("n", "-i", ":split<CR>", { noremap = true, silent = true, desc = "Open a horizontal split" })
vim.keymap.set("n", "-s", ":vsplit<CR>", { noremap = true, silent = true, desc = "Open a vertical split" })
vim.keymap.set("n", "<BS>", ":bp<CR>", { noremap = true, silent = true, desc = "Previous buffer" })

local function is_git_repo()
vim.fn.system("git rev-parse --is-inside-work-tree 2>/dev/null")
Expand All @@ -54,3 +51,59 @@ vim.keymap.set("n", "<Space>-", function()
Snacks.bufdelete()
end
end, { noremap = true, desc = "Close buffer" })

vim.cmd([[
" Buffer switching: https://vi.stackexchange.com/a/9255
function! EvanSwitchBufNum(num)
let l:buffers = filter(range(1, bufnr('$')), 'buflisted(v:val)')
let l:input = a:num . ''
while 1
let l:cnt = 0
let l:i = 0
" count matches
while l:i<len(l:buffers)
let l:bn = l:buffers[l:i] . ''
if l:input==l:bn[0:len(l:input)-1]
let l:example = l:bn
let l:cnt+=1
endif
let l:i+=1
endwhile
" no matches
if l:cnt==0 && len(l:input)>0
echo 'no buffer [' . l:input . ']'
return ''
elseif l:cnt==1 && l:input==l:example
return ':b ' . l:example . "\<CR>"
endif
echo ':b ' . l:input
let l:n = getchar()
if l:n==char2nr("\<BS>") || l:n==char2nr("\<C-h>")
" delete one word
if len(l:input)>=2
let l:input = l:input[0:len(l:input)-2]
else
let l:input = ''
endif
elseif l:n==char2nr("\<CR>") || (l:n<char2nr('0') || l:n>char2nr('9'))
return ':b ' . l:input . "\<CR>"
else
let l:input = l:input . nr2char(l:n)
endif
let g:n = l:n
endwhile
endfunc
nnoremap <expr> <Space>1 EvanSwitchBufNum(1)
nnoremap <expr> <Space>2 EvanSwitchBufNum(2)
nnoremap <expr> <Space>3 EvanSwitchBufNum(3)
nnoremap <expr> <Space>4 EvanSwitchBufNum(4)
nnoremap <expr> <Space>5 EvanSwitchBufNum(5)
nnoremap <expr> <Space>6 EvanSwitchBufNum(6)
nnoremap <expr> <Space>7 EvanSwitchBufNum(7)
nnoremap <expr> <Space>8 EvanSwitchBufNum(8)
nnoremap <expr> <Space>9 EvanSwitchBufNum(9)
]])
50 changes: 34 additions & 16 deletions nvim/lua/plugins/builtins.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
return {
{
"nvim-neo-tree/neo-tree.nvim",
keys = {
{ "<leader>e", false },
{ "<leader>E", false },
{
"<leader>t",
function()
require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() })
end,
desc = "Explorer NeoTree (Root Dir)",
},
},
"folke/noice.nvim",
enabled = false,
},
{
"saghen/blink.cmp",
Expand Down Expand Up @@ -109,6 +99,9 @@ return {
hint = icons.diagnostics.Hint,
},
},
},
lualine_y = {
{ "filetype", icon_only = false, separator = "", padding = { left = 1, right = 1 } },
{
"diff",
symbols = {
Expand All @@ -128,11 +121,8 @@ return {
end,
},
},
lualine_y = {
{ "filetype", icon_only = false, separator = "", padding = { left = 1, right = 1 } },
},
lualine_z = {
{ "location", padding = { left = 0, right = 1 } },
{ "location", padding = { left = 1, right = 1 } },
},
},
extensions = { "neo-tree", "lazy", "fzf" },
Expand Down Expand Up @@ -161,4 +151,32 @@ return {
return opts
end,
},
{
"akinsho/bufferline.nvim",
opts = {
highlights = {
buffer_selected = {
fg = {
attribute = "fg",
highlight = "CursorLineNr",
},
},
buffer_visible = {
fg = {
attribute = "fg",
highlight = "LineNr",
},
},
},
options = {
always_show_bufferline = true,
indicator = { style = "underline" },
show_buffer_close_icons = false,
show_close_icon = false,
modified_icon = "[+]",
numbers = "buffer_id",
tab_size = 12,
},
},
},
}
3 changes: 3 additions & 0 deletions nvim/lua/plugins/colorscheme.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ return {
return {
LineNr = { fg = colors.peach },
CursorLineNr = { fg = colors.teal, bg = colors.overlay0, style = { "bold" } },
Folded = { bg = colors.surface2 },

Conceal = { fg = colors.yellow },
Identifier = { style = { "bold" } },
Include = { fg = colors.green },
Function = { fg = colors.red },
PreProc = { fg = colors.maroon, style = { "bold" } },
Special = { fg = colors.green, style = { "bold" } },
Statement = { fg = colors.sapphire, style = { "bold" } },

texTitleArg = { fg = colors.base, style = { "bold" } },
texEnvArgName = { fg = colors.red, style = { "bold" } },
texEnvOpt = { fg = colors.text, style = { "bold" } },
Expand Down

0 comments on commit f639c1b

Please sign in to comment.