aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Weigl-Bosker <stefan@s00.xyz>2025-06-19 10:24:34 -0400
committerStefan Weigl-Bosker <stefan@s00.xyz>2025-06-19 10:24:34 -0400
commit5aaf50744a115ebbc123d7fb389bd3bcbb1cd963 (patch)
tree927aad87675339dc0be61ac81e006f573b9f71a2
parent666b313cd84b1c67c20da300bf9fbb356df199c1 (diff)
downloadhome-nvim.tar.gz
modules/nvim: reworknvim
-rw-r--r--modules/neovim/default.nix197
-rw-r--r--modules/neovim/nvim/init.lua5
-rw-r--r--modules/neovim/nvim/lua/config/colorscheme.lua35
-rw-r--r--modules/neovim/nvim/lua/config/keybinds.lua51
-rw-r--r--modules/neovim/nvim/lua/config/settings.lua36
-rw-r--r--modules/neovim/nvim/lua/config/textobjects.lua4
-rw-r--r--modules/neovim/nvim/lua/config/treesitter.lua8
7 files changed, 182 insertions, 154 deletions
diff --git a/modules/neovim/default.nix b/modules/neovim/default.nix
index f3200b3..8399307 100644
--- a/modules/neovim/default.nix
+++ b/modules/neovim/default.nix
@@ -2,16 +2,53 @@
let
cfg = config.modules.neovim;
scheme = config.modules.scheme;
- fromGitHub = ref: repo: pkgs.vimUtils.buildVimPlugin {
- pname = "${lib.strings.sanitizeDerivationName repo}"; version = ref; src = builtins.fetchGit {
- url = "https://github.com/${repo}.git";
- ref = ref;
- };
- doCheck = false;
- };
tsparsers = pkgs.symlinkJoin {
+ # if we don't symlink, startuptime grows by an order of magnitude because of long runtimepath
name = "tsparsers";
- paths = (pkgs.vimPlugins.nvim-treesitter.withAllGrammars).dependencies;
+ # paths = (pkgs.vimPlugins.nvim-treesitter.withAllGrammars).dependencies;
+ paths = (pkgs.vimPlugins.nvim-treesitter.withPlugins (p: with p; [
+ tree-sitter-nix
+ tree-sitter-nu
+ tree-sitter-go
+ tree-sitter-rst
+ tree-sitter-lua
+ tree-sitter-css
+ tree-sitter-yaml
+ tree-sitter-toml
+ tree-sitter-scss
+ tree-sitter-json
+ tree-sitter-html
+ tree-sitter-fish
+ tree-sitter-bash
+ tree-sitter-query
+ tree-sitter-ocaml
+ tree-sitter-ocaml-interface
+ tree-sitter-latex
+ tree-sitter-python
+ tree-sitter-bibtex
+ tree-sitter-verilog
+ tree-sitter-comment
+ tree-sitter-dockerfile
+ tree-sitter-make
+ tree-sitter-cmake
+ tree-sitter-verilog
+ tree-sitter-scheme
+ tree-sitter-llvm
+ tree-sitter-html
+ tree-sitter-glsl
+ tree-sitter-devicetree
+ tree-sitter-cuda
+ tree-sitter-c
+ tree-sitter-cpp
+ tree-sitter-lua
+ tree-sitter-zig
+ tree-sitter-rust
+ tree-sitter-haskell
+ tree-sitter-toml
+ tree-sitter-markdown
+ tree-sitter-markdown-inline
+ tree-sitter-tablegen
+ ])).dependencies;
};
in
{
@@ -30,11 +67,6 @@ in
recursive = true;
};
- xdg.configFile."nvim/colors" = {
- source = ./nvim/colors;
- recursive = true;
- };
-
# home.sessionVariables.MANPAGER = "nvim +Man!";
programs.neovim = {
@@ -44,9 +76,16 @@ in
vimAlias = false;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
+ # lazy loading
+ lz-n
+
+ # preconfigured treesitter parsers
nvim-treesitter
+ tsparsers
+
+ # colorschemes. TODO: delete
base16-nvim
- # nvim-treesitter.withAllGrammars
+
{
plugin = nvim-highlight-colors;
type = "lua";
@@ -61,61 +100,103 @@ in
}
'';
}
- # (nvim-treesitter.withPlugins (p: with p; [
- # tree-sitter-nix
- # tree-sitter-make
- # tree-sitter-cmake
- # tree-sitter-verilog
- # tree-sitter-scheme
- # tree-sitter-llvm
- # tree-sitter-html
- # tree-sitter-glsl
- # tree-sitter-devicetree
- # tree-sitter-cuda
- # tree-sitter-c
- # tree-sitter-cpp
- # tree-sitter-lua
- # tree-sitter-zig
- # tree-sitter-rust
- # tree-sitter-haskell
- # tree-sitter-toml
- # tree-sitter-markdown
- # tree-sitter-markdown-inline
- # tree-sitter-tablegen
- # ]))
{
plugin = lean-nvim;
- config =
+ optional = true;
+ type = "lua";
+ config =
# lua
''
- require('lean').setup{ mappings = true }
+ require("lz.n").load({
+ "lean",
+ ft = "lean",
+ after = function()
+ require('lean').setup({ mappings = true })
+ end,
+ })
'';
- type = "lua";
}
- plenary-nvim
- mini-icons
- oil-nvim
+
tmux-nvim
- # noice-nvim
nvim-lspconfig
- # blink-cmp
- telescope-nvim
+
+ {
+ plugin = telescope-nvim;
+ optional = true;
+ type = "lua";
+ config =
+ # lua
+ ''
+ require("lz.n").load({
+ "telescope.nvim",
+ cmd = "Telescope",
+ after = function()
+ require('telescope').setup({})
+ require('telescope').load_extension('fzf')
+ end,
+ })
+ '';
+ }
telescope-fzf-native-nvim
- # fzf-lua
-# https://github.com/ibhagwan/fzf-lua/commit/26095d98c2969730457bf5b483919280e2cfb8bb
- # (fromGitHub "HEAD" "ibhagwan/fzf-lua")
- # fzf-lua.overrideAttrs (finalAttrs: previousAttrs: {
- # previousAttrs.doCheck = false;
- # })
- vim-obsession
- (pkgs.neovimUtils.buildNeovimPlugin {
- luaAttr = pkgs.luaPackages.fzf-lua;
- doCheck = false;
- })
+
+ # textobjects
+ mini-ai
+ {
+ plugin = mini-pairs;
+ type = "lua";
+ config =
+ # lua
+ ''
+ require("mini.pairs").setup()
+ '';
+ }
+ {
+ plugin = mini-surround;
+ type = "lua";
+ config =
+ # lua
+ ''
+ require("mini.surround").setup({ silent = true })
+ '';
+ }
+ {
+ plugin = mini-trailspace;
+ type = "lua";
+ config =
+ # lua
+ ''
+ require("mini.trailspace").setup()
+ '';
+ }
+ {
+ plugin = mini-splitjoin;
+ type = "lua";
+ config =
+ # lua
+ ''
+ require("mini.splitjoin").setup({
+ mappings = { toggle = "", split = "", join = "" },
+ })
+ '';
+ }
+ {
+ plugin = treesj;
+ type = "lua";
+ config =
+ # lua
+ ''
+ require("treesj").setup({ use_default_keymaps = false, notify = false})
+ --require("lz.n").load({
+ -- "treesj",
+ -- cmd = {'TSJSplit', 'TSJToggle', 'TSJJoin'},
+ -- after = function()
+ -- require("treesj").setup(use_default_keymaps = false)
+ -- end,
+ -- })
+ '';
+ }
];
- # extraLuaPackages = ps: with ps; [
- # ];
extraLuaConfig =
''
${builtins.readFile ./nvim/init.lua}
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('<leader>tn', ':tabnew<CR>', { desc = "Open a new tab" })
nmap('<leader>tc', ':tabc<CR>', { desc = "Close the current tab" })
@@ -37,29 +37,34 @@ nmap('<leader>wm', '<C-w><C-h>', { desc = "Focus window left of the current one"
nmap('<leader>wn', '<C-w><C-j>', { desc = "Focus window below the current one" })
nmap('<leader>we', '<C-w><C-k>', { desc = "Focus window above the current one" })
nmap('<leader>wi', '<C-w><C-l>', { desc = "Focus window right of the current one" })
--- nmap('<C-m>', '<C-w><C-h>', { desc = "Focus window left of the current one" })
--- nmap('<C-n>', '<C-w><C-j>', { desc = "Focus window below the current one" })
--- nmap('<C-e>', '<C-w><C-k>', { desc = "Focus window above the current one" })
--- nmap('<C-i>', '<C-w><C-l>', { desc = "Focus window right of the current one" })
map({'n', 't', 'i'}, '<M-m>', function() require("tmux").move_left() end, { desc = "Focus window left of the current one" })
map({'n', 't', 'i'}, '<M-n>', function() require("tmux").move_bottom() end, { desc = "Focus window below the current one" })
map({'n', 't', 'i'}, '<M-e>', function() require("tmux").move_top() end, { desc = "Focus window above the current one" })
map({'n', 't', 'i'}, '<M-i>', function() require("tmux").move_right() end, { desc = "Focus window right of the current one" })
+
map({'n', 't', 'i'}, '<M-M>', function() require("tmux").resize_left() end, { desc = "Resize left side of split" })
map({'n', 't', 'i'}, '<M-N>', function() require("tmux").resize_bottom() end, { desc = "Resize bottom side of split" })
map({'n', 't', 'i'}, '<M-E>', function() require("tmux").resize_top() end, { desc = "Resize top side of split" })
map({'n', 't', 'i'}, '<M-I>', function() require("tmux").resize_right() end, { desc = "Resize right side of split" })
--- nmap('<leader>fo', '<cmd>Telescope find_files<CR>', { silent = true })
-nmap('<leader>fo', '<cmd>FzfLua files<CR>', { silent = true })
--- nmap('<leader>fe', '<cmd>lua require("oil").open(nil, { preview = { split = "aboveleft" } })<CR>', { silent = true })
-nmap('<leader>fe', '<cmd>lua require("oil").toggle_float()<CR>', { silent = true })
-
--- nmap('<leader>?', '<cmd>Telescope live_grep<CR>', { silent = true })
-nmap('<leader>?', '<cmd>FzfLua live_grep_native<CR>', { silent = true })
+nmap('<leader>fo', '<cmd>Telescope find_files<CR>', { silent = true })
+nmap('<leader>?', '<cmd>Telescope live_grep<CR>', { silent = true })
nmap('<leader>to', '<cmd>te<CR>', { 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', '<Cmd>TSJToggle<CR>', opts)
+ vim.keymap.set('n', 'gS', '<Cmd>TSJSplit<CR>', opts)
+ vim.keymap.set('n', 'gJ', '<Cmd>TSJJoin<CR>', opts)
+ else
+ vim.keymap.set('n', 'S', '<Cmd>lua MiniSplitJoin.toggle()<CR>', opts)
+ vim.keymap.set('n', 'gS', '<Cmd>lua MiniSplitJoin.split()<CR>', opts)
+ vim.keymap.set('n', 'gJ', '<Cmd>lua MiniSplitJoin.join()<CR>', 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=<C-n>]]
-
-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 = {