From 5aaf50744a115ebbc123d7fb389bd3bcbb1cd963 Mon Sep 17 00:00:00 2001 From: Stefan Weigl-Bosker Date: Thu, 19 Jun 2025 10:24:34 -0400 Subject: modules/nvim: rework --- modules/neovim/nvim/init.lua | 5 +-- modules/neovim/nvim/lua/config/colorscheme.lua | 35 ------------------ modules/neovim/nvim/lua/config/keybinds.lua | 51 ++++++++++++++------------ modules/neovim/nvim/lua/config/settings.lua | 36 ++++-------------- modules/neovim/nvim/lua/config/textobjects.lua | 4 ++ modules/neovim/nvim/lua/config/treesitter.lua | 8 ++-- 6 files changed, 43 insertions(+), 96 deletions(-) create mode 100644 modules/neovim/nvim/lua/config/textobjects.lua (limited to 'modules/neovim/nvim') diff --git a/modules/neovim/nvim/init.lua b/modules/neovim/nvim/init.lua index 8a4de01..900d505 100644 --- a/modules/neovim/nvim/init.lua +++ b/modules/neovim/nvim/init.lua @@ -3,8 +3,5 @@ require("config.keybinds") require("config.colorscheme") require("config.lsp") require("config.treesitter") -require("config.icons") -require("config.fzf") -require("config.oil") --- require("config.statusline") require("config.tmux") +require("config.textobjects") diff --git a/modules/neovim/nvim/lua/config/colorscheme.lua b/modules/neovim/nvim/lua/config/colorscheme.lua index 6a426f0..6510131 100644 --- a/modules/neovim/nvim/lua/config/colorscheme.lua +++ b/modules/neovim/nvim/lua/config/colorscheme.lua @@ -14,40 +14,5 @@ vim.api.nvim_create_autocmd("ColorScheme", { callback = function(args) hi StatusLine guibg=bg guifg=fg hi StatusLineNC guibg=bg ]] - vim.api.nvim_set_hl(0, 'FzfLuaBorder', { fg = colors.base01 }) - - -- -- i dislike syntax highlighting - -- -- vim.api.nvim_set_hl(0, 'Comment', {}) - -- vim.api.nvim_set_hl(0, 'Constant', {}) - -- -- vim.api.nvim_set_hl(0, 'String', {}) - -- vim.api.nvim_set_hl(0, 'Character', { link = "String" }) - -- vim.api.nvim_set_hl(0, 'Number', {}) - -- vim.api.nvim_set_hl(0, 'Boolean', {}) - -- vim.api.nvim_set_hl(0, 'Float', {}) - -- vim.api.nvim_set_hl(0, 'Identifier', {}) - -- vim.api.nvim_set_hl(0, 'Function', {}) - -- vim.api.nvim_set_hl(0, 'Statement', {}) - -- vim.api.nvim_set_hl(0, 'Conditional', {}) - -- vim.api.nvim_set_hl(0, 'Repeat', {}) - -- vim.api.nvim_set_hl(0, 'Label', {}) - -- vim.api.nvim_set_hl(0, 'Operator', {}) - -- vim.api.nvim_set_hl(0, 'Keyword', {}) - -- vim.api.nvim_set_hl(0, 'Exception', {}) - -- vim.api.nvim_set_hl(0, 'PreProc', {}) - -- vim.api.nvim_set_hl(0, 'Include', {}) - -- vim.api.nvim_set_hl(0, 'Define', {}) - -- vim.api.nvim_set_hl(0, 'Macro', {}) - -- vim.api.nvim_set_hl(0, 'PreCondit', {}) - -- vim.api.nvim_set_hl(0, 'Type', {}) - -- vim.api.nvim_set_hl(0, 'StorageClass', {}) - -- vim.api.nvim_set_hl(0, 'Structure', {}) - -- vim.api.nvim_set_hl(0, 'Typedef', {}) - -- vim.api.nvim_set_hl(0, 'Special', {}) - -- vim.api.nvim_set_hl(0, 'SpecialChar', { link = 'String' }) - -- vim.api.nvim_set_hl(0, 'Tag', {}) - -- vim.api.nvim_set_hl(0, 'Delimiter', {}) - -- -- vim.api.nvim_set_hl(0, 'SpecialComment', {}) - -- vim.api.nvim_set_hl(0, 'Debug', {}) - -- -- vim.api.nvim_set_hl(0, 'Underlined', {}) end}) diff --git a/modules/neovim/nvim/lua/config/keybinds.lua b/modules/neovim/nvim/lua/config/keybinds.lua index 4f8df1b..8dbc0fc 100644 --- a/modules/neovim/nvim/lua/config/keybinds.lua +++ b/modules/neovim/nvim/lua/config/keybinds.lua @@ -14,15 +14,15 @@ local function swapnv(bind1, bind2) swap({'n', 'v'}, bind1, bind2) end -swapnv('m', 'h') -swapnv('n', 'j') -swapnv('e', 'k') -swapnv('i', 'l') - -swapnv('M', 'H') -swapnv('N', 'J') ---swapnv('E', 'K') -swapnv('I', 'L') +-- swapnv('m', 'h') +-- swapnv('n', 'j') +-- swapnv('e', 'k') +-- swapnv('i', 'l') +-- +-- swapnv('M', 'H') +-- swapnv('N', 'J') +-- swapnv('E', 'K') +-- swapnv('I', 'L') nmap('tn', ':tabnew', { desc = "Open a new tab" }) nmap('tc', ':tabc', { desc = "Close the current tab" }) @@ -37,29 +37,34 @@ nmap('wm', '', { desc = "Focus window left of the current one" nmap('wn', '', { desc = "Focus window below the current one" }) nmap('we', '', { desc = "Focus window above the current one" }) nmap('wi', '', { desc = "Focus window right of the current one" }) --- nmap('', '', { desc = "Focus window left of the current one" }) --- nmap('', '', { desc = "Focus window below the current one" }) --- nmap('', '', { desc = "Focus window above the current one" }) --- nmap('', '', { desc = "Focus window right of the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_left() end, { desc = "Focus window left of the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_bottom() end, { desc = "Focus window below the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_top() end, { desc = "Focus window above the current one" }) map({'n', 't', 'i'}, '', function() require("tmux").move_right() end, { desc = "Focus window right of the current one" }) + map({'n', 't', 'i'}, '', function() require("tmux").resize_left() end, { desc = "Resize left side of split" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_bottom() end, { desc = "Resize bottom side of split" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_top() end, { desc = "Resize top side of split" }) map({'n', 't', 'i'}, '', function() require("tmux").resize_right() end, { desc = "Resize right side of split" }) --- nmap('fo', 'Telescope find_files', { silent = true }) -nmap('fo', 'FzfLua files', { silent = true }) --- nmap('fe', 'lua require("oil").open(nil, { preview = { split = "aboveleft" } })', { silent = true }) -nmap('fe', 'lua require("oil").toggle_float()', { silent = true }) - --- nmap('?', 'Telescope live_grep', { silent = true }) -nmap('?', 'FzfLua live_grep_native', { silent = true }) +nmap('fo', 'Telescope find_files', { silent = true }) +nmap('?', 'Telescope live_grep', { silent = true }) nmap('to', 'te', { silent = true; desc = "Open a terminal buffer in the current window." }) - - - +vim.api.nvim_create_autocmd({ 'FileType' }, { + pattern = '*', + callback = function() + local opts = { buffer = true } + local langs = require'treesj.langs'['presets'] + if langs[vim.bo.filetype] then + vim.keymap.set('n', 'S', 'TSJToggle', opts) + vim.keymap.set('n', 'gS', 'TSJSplit', opts) + vim.keymap.set('n', 'gJ', 'TSJJoin', opts) + else + vim.keymap.set('n', 'S', 'lua MiniSplitJoin.toggle()', opts) + vim.keymap.set('n', 'gS', 'lua MiniSplitJoin.split()', opts) + vim.keymap.set('n', 'gJ', 'lua MiniSplitJoin.join()', opts) + end + end +}) diff --git a/modules/neovim/nvim/lua/config/settings.lua b/modules/neovim/nvim/lua/config/settings.lua index 75f1c41..05d94a9 100644 --- a/modules/neovim/nvim/lua/config/settings.lua +++ b/modules/neovim/nvim/lua/config/settings.lua @@ -1,52 +1,30 @@ vim.g.mapleader = ' ' - +vim.loader.enable({enable = true}) vim.o.relativenumber = true vim.o.number = true vim.o.tabstop = 2 vim.o.shiftwidth = 2 -vim.o.relativenumber = false - +vim.o.relativenumber = true vim.o.splitright = true vim.o.splitbelow = true -vim.o.scrolloff = 15 -vim.o.sidescrolloff = 12 +vim.o.scrolloff = 999 +vim.o.sidescrolloff = 999 vim.o.wrap = false -vim.o.lbr = true -vim.o.shortmess = "tToOCFIsWcCi" +vim.o.linebreak = true +vim.o.shortmess = "tToOFIsWcCi" vim.o.termguicolors = true vim.opt.fillchars = {eob = " "} vim.o.smd = false -vim.opt.laststatus=2 +vim.opt.laststatus=0 vim.opt.cmdheight=0 --- vim.opt.statusline="%=%f%=%r %p%% « %l, %c %y" --- vim.opt.statusline="%f%=%p%% « %l, %c " --- vim.opt.winbar="%!nvim_treesitter#statusline()" --- vim.cmd[[ --- hi StatusLineNC guibg=none --- hi StatusLine guibg=none --- ]] --- vim.cmd[[ --- hi LineNr guifg=bg --- hi LineNrAbove guifg=bg --- hi LineNrBelow guifg=bg --- ]] vim.opt.pumheight = 6 vim.opt.expandtab = true vim.o.mouse="" --- vim.o.guicursor="" vim.o.swapfile=false vim.opt.foldmethod = "expr" -vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()" - ---vim.opt.foldcolumn = "0" vim.opt.foldlevel = 99 vim.opt.foldlevelstart = 99 vim.opt.foldenable=true --- vim.cmd[[syntax off]] --- vim.o.winborder = 'rounded' breaks telescope - vim.cmd[[set wildchar=]] - -vim.g.loaded_matchparen = 1 vim.cmd[[cnoreabbrev ts lua vim.treesitter.start()]] require('vim._extui').enable({}) diff --git a/modules/neovim/nvim/lua/config/textobjects.lua b/modules/neovim/nvim/lua/config/textobjects.lua new file mode 100644 index 0000000..6226530 --- /dev/null +++ b/modules/neovim/nvim/lua/config/textobjects.lua @@ -0,0 +1,4 @@ +-- also see treesitter config +require("mini.ai").setup({ + silent = true, +}) diff --git a/modules/neovim/nvim/lua/config/treesitter.lua b/modules/neovim/nvim/lua/config/treesitter.lua index d556f96..69588e1 100644 --- a/modules/neovim/nvim/lua/config/treesitter.lua +++ b/modules/neovim/nvim/lua/config/treesitter.lua @@ -1,14 +1,12 @@ require("nvim-treesitter.configs").setup { - highlight = { enable = false }, - -- highlight = { enable = true }, + highlight = { enable = true }, indent = { enable = false }, incremental_selection = { enable = true, keymaps = { -- init_selection = "gnn", - init_selection = "g+", - node_incremental = "+", - node_decremental = "_", + node_incremental = "aa", + node_decremental = "ii", }, }, -- highlight = { -- cgit v1.2.3