1

Neovim: Update neovim module

This commit is contained in:
2024-06-05 01:43:22 +02:00
parent c7b0fb3ba0
commit 94e665a424
4 changed files with 304 additions and 61 deletions

View File

@ -95,22 +95,23 @@ in {
# p.std2 # p.std2
# ]; # ];
# TODO: Resize splits on window-resize
autoCmd = [ autoCmd = [
{ {
event = ["BufWritePost"]; event = ["BufWritePost"];
callback.__raw = "function() require('lint').try_lint() end"; callback.__raw = ''
function()
if not vim.g.disable_autolint then
require("lint").try_lint()
end
end
'';
} }
# Now setup directly in conform
# {
# event = ["BufWritePre"];
# callback.__raw = "function() require('conform').format() end";
# }
{ {
event = ["TextYankPost"]; event = ["TextYankPost"];
callback.__raw = "function() vim.highlight.on_yank() end"; callback.__raw = "function() vim.highlight.on_yank() end";
} }
{ {
# Resize splits when entire window is resized by wm
event = ["VimResized"]; event = ["VimResized"];
callback.__raw = '' callback.__raw = ''
function() function()
@ -374,11 +375,9 @@ in {
''; '';
}; };
# TODO: Only colorize html/css/scss/sass...
colorizer = { colorizer = {
name = "colorizer"; name = "colorizer";
pkg = pkgs.vimPlugins.nvim-colorizer-lua; pkg = pkgs.vimPlugins.nvim-colorizer-lua;
enabled = false;
lazy = true; lazy = true;
event = ["BufReadPost" "BufNewFile"]; event = ["BufReadPost" "BufNewFile"];
config = '' config = ''
@ -471,11 +470,11 @@ in {
}; };
}; };
# TODO: Config
flash = { flash = {
name = "flash"; name = "flash";
pkg = pkgs.vimPlugins.flash-nvim; pkg = pkgs.vimPlugins.flash-nvim;
lazy = false; lazy = true;
keys = ["s" "S" "f" "F" "t" "T"];
config = '' config = ''
function(_, opts) function(_, opts)
require("flash").setup(opts) require("flash").setup(opts)
@ -525,6 +524,50 @@ in {
# Don't call setup! # Don't call setup!
}; };
indent-blankline = {
name = "indent-blankline";
pkg = pkgs.vimPlugins.indent-blankline-nvim;
lazy = false;
config = ''
function(_, opts)
-- Regular setup
require("ibl").setup(opts)
-- Setup IBL with rainbow-delimiters
-- local highlight = {
-- "RainbowRed",
-- "RainbowYellow",
-- "RainbowBlue",
-- "RainbowOrange",
-- "RainbowGreen",
-- "RainbowViolet",
-- "RainbowCyan",
-- }
-- local hooks = require("ibl.hooks")
-- -- create the highlight groups in the highlight setup hook, so they are reset
-- -- every time the colorscheme changes
-- hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
-- vim.api.nvim_set_hl(0, "RainbowRed", { fg = "#E06C75" })
-- vim.api.nvim_set_hl(0, "RainbowYellow", { fg = "#E5C07B" })
-- vim.api.nvim_set_hl(0, "RainbowBlue", { fg = "#61AFEF" })
-- vim.api.nvim_set_hl(0, "RainbowOrange", { fg = "#D19A66" })
-- vim.api.nvim_set_hl(0, "RainbowGreen", { fg = "#98C379" })
-- vim.api.nvim_set_hl(0, "RainbowViolet", { fg = "#C678DD" })
-- vim.api.nvim_set_hl(0, "RainbowCyan", { fg = "#56B6C2" })
-- end)
-- vim.g.rainbow_delimiters = { highlight = highlight }
-- opts.scope = {highlight = highlight}
-- Call setup function
-- require("ibl").setup(opts)
-- hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark)
end
'';
};
illuminate = { illuminate = {
name = "illuminate"; name = "illuminate";
pkg = pkgs.vimPlugins.vim-illuminate; pkg = pkgs.vimPlugins.vim-illuminate;
@ -550,6 +593,76 @@ in {
}; };
}; };
_navic = {
name = "navic";
pkg = pkgs.vimPlugins.nvim-navic;
lazy = true;
config = ''
function(_, opts)
navic = require("nvim-navic")
navic.setup(opts)
-- Register navic with lualine's winbar (NOTE: using incline currently)
-- TODO: The setup function should probably only be ran once
-- require("lualine").setup({
-- winbar = {
-- lualine_c = {
-- {
-- function()
-- return navic.get_location()
-- end,
-- cond = function()
-- return navic.is_available()
-- end
-- }
-- }
-- }
-- })
end
'';
opts = {
lsp.auto_attach = true;
click = true;
highlight = true;
depth_limit = 5;
};
};
incline = {
name = "incline";
pkg = let
nvim-incline = pkgs.vimUtils.buildVimPlugin {
name = "nvim-incline";
src = pkgs.fetchFromGitHub {
owner = "b0o";
repo = "incline.nvim";
rev = "16fc9c073e3ea4175b66ad94375df6d73fc114c0";
sha256 = "sha256-5DoIvIdAZV7ZgmQO2XmbM3G+nNn4tAumsShoN3rDGrs=";
};
};
in
nvim-incline;
dependencies = [_navic];
lazy = true;
event = ["BufReadPost" "BufNewFile"];
config = ''
function(_, opts)
require("incline").setup(opts)
end
'';
opts = {
window = {
padding = 0;
margin = {
horizontal = 0;
vertical = 0;
};
};
render.__raw = builtins.readFile ./inclineNavic.lua;
};
};
intellitab = { intellitab = {
name = "intellitab"; name = "intellitab";
pkg = pkgs.vimPlugins.intellitab-nvim; pkg = pkgs.vimPlugins.intellitab-nvim;
@ -609,6 +722,35 @@ in {
}; };
}; };
# Newer alternative to neodev
_lazydev = {
name = "lazydev";
pkg = let
nvim-lazydev = pkgs.vimUtils.buildVimPlugin {
name = "nvim-lazydev";
src = pkgs.fetchFromGitHub {
owner = "folke";
repo = "lazydev.nvim";
rev = "8146b3ad692ae7026fea1784fd5b13190d4f883c"; # v1.4
sha256 = "sha256-JGRjwRDx2Gdp/EBwO2XmWRGOWmHDu0XAzLps+/RSpYk=";
};
};
in
nvim-lazydev;
ft = ["lua"];
config = ''
function(_, opts)
require("lazydev").setup(opts)
end
'';
# opts = {
# library = [
# "~/NixFlake/config/neovim/store"
# ];
# };
};
# Predecessor of lazydev
_neodev = { _neodev = {
name = "neodev"; name = "neodev";
pkg = pkgs.vimPlugins.neodev-nvim; pkg = pkgs.vimPlugins.neodev-nvim;
@ -632,7 +774,7 @@ in {
}; };
}; };
# TODO: This entire thing is rough, maybe I should look for another way... # NOTE: This entire thing is rough, maybe I should look for another way...
lspconfig = { lspconfig = {
name = "lspconfig"; name = "lspconfig";
pkg = pkgs.vimPlugins.nvim-lspconfig; pkg = pkgs.vimPlugins.nvim-lspconfig;
@ -640,7 +782,8 @@ in {
cmd = ["LspInfo"]; cmd = ["LspInfo"];
event = ["BufReadPost" "BufNewFile"]; event = ["BufReadPost" "BufNewFile"];
dependencies = [ dependencies = [
_neodev # Has to be setup before lspconfig _lazydev
# _neodev # Has to be setup before lspconfig
]; ];
config = let config = let
servers = mylib.generators.toLuaObject [ servers = mylib.generators.toLuaObject [
@ -692,6 +835,9 @@ in {
]; ];
in '' in ''
function(_, opts) function(_, opts)
-- Make LspInfo window border rounded
require("lspconfig.ui.windows").default_options.border = "rounded"
local __lspOnAttach = function(client, bufnr) end local __lspOnAttach = function(client, bufnr) end
local __lspCapabilities = function() local __lspCapabilities = function()
@ -791,6 +937,7 @@ in {
navbuddy = { navbuddy = {
name = "navbuddy"; name = "navbuddy";
pkg = pkgs.vimPlugins.nvim-navbuddy; pkg = pkgs.vimPlugins.nvim-navbuddy;
dependencies = [_navic];
lazy = true; lazy = true;
cmd = ["Navbuddy"]; cmd = ["Navbuddy"];
config = '' config = ''
@ -805,24 +952,6 @@ in {
}; };
}; };
# TODO: Doesn't show up
navic = {
name = "navic";
pkg = pkgs.vimPlugins.nvim-navic;
lazy = false;
config = ''
function(_, opts)
require("nvim-navic").setup(opts)
end
'';
opts = {
lsp.auto_attach = true;
click = true;
highlight = true;
};
};
# TODO: Notification spam on filter (when searching for ignored/non-existing file)
neo-tree = { neo-tree = {
name = "neo-tree"; name = "neo-tree";
pkg = pkgs.vimPlugins.neo-tree-nvim; pkg = pkgs.vimPlugins.neo-tree-nvim;
@ -1105,6 +1234,27 @@ in {
}; };
}; };
_treesitter-context = {
name = "treesitter-context";
pkg = pkgs.vimPlugins.nvim-treesitter-context;
lazy = true;
config = ''
function(_, opts)
require("treesitter-context").setup(opts)
end
'';
opts = {
max_lines = 3;
line_numbers = false;
};
};
_treesitter-refactor = {
name = "treesitter-refactor";
pkg = pkgs.vimPlugins.nvim-treesitter-refactor;
lazy = true;
};
treesitter = let treesitter = let
nvim-plugintree = pkgs.vimPlugins.nvim-treesitter.withAllGrammars; nvim-plugintree = pkgs.vimPlugins.nvim-treesitter.withAllGrammars;
treesitter-parsers = pkgs.symlinkJoin { treesitter-parsers = pkgs.symlinkJoin {
@ -1114,6 +1264,10 @@ in {
in { in {
name = "treesitter"; name = "treesitter";
pkg = pkgs.vimPlugins.nvim-treesitter; pkg = pkgs.vimPlugins.nvim-treesitter;
dependencies = [
# _treesitter-context # Ugly
# _treesitter-refactor # Ugly
];
lazy = true; lazy = true;
cmd = ["TSModuleInfo"]; cmd = ["TSModuleInfo"];
event = ["BufReadPost" "BufNewFile"]; event = ["BufReadPost" "BufNewFile"];
@ -1135,12 +1289,18 @@ in {
enable = true; enable = true;
# disable = ["python" "yaml"]; # NOTE: Check how bad it is # disable = ["python" "yaml"]; # NOTE: Check how bad it is
}; };
highlight = { highlight = {
enable = true; enable = true;
# disable = ["yaml"]; # disable = ["yaml"];
additional_vim_regex_highlighting = false; additional_vim_regex_highlighting = false;
}; };
# refactor = {
# highlight_definitions.enable = true;
# highlight_current_scope.enable = false; # Ugly
# };
# TODO: Doesn't work # TODO: Doesn't work
incremental_selection = { incremental_selection = {
enable = true; enable = true;
@ -1178,6 +1338,28 @@ in {
''; '';
}; };
twilight = {
name = "twilight";
pkg = pkgs.vimPlugins.twilight-nvim;
config = ''
function(_, opts)
require("twilight").setup(opts)
end
'';
opts = {
dimming.alpha = 0.75;
context = 15;
treesitter = true;
expand = [
"function"
"method"
"table"
"if_statement"
];
# exclude = []; # Excluded filetypes
};
};
_promise = { _promise = {
name = "promise"; name = "promise";
pkg = pkgs.vimPlugins.promise-async; pkg = pkgs.vimPlugins.promise-async;
@ -1250,17 +1432,19 @@ in {
autopairs autopairs
bbye bbye
better-escape better-escape
# chadtree # chadtree # NOTE: Using neo-tree
clangd-extensions clangd-extensions
cmp cmp
colorizer # colorizer # TODO: Only colorize html/css/scss/sass...
comment comment
conform conform
flash flash
gitmessenger gitmessenger
gitsigns gitsigns
haskell-tools haskell-tools
# indent-blankline # NOTE: Too much noise
illuminate illuminate
# incline # TODO: Bad styling
intellitab intellitab
lastplace lastplace
lazygit lazygit
@ -1269,7 +1453,6 @@ in {
lualine lualine
luasnip luasnip
navbuddy navbuddy
navic
neo-tree neo-tree
noice noice
rainbow-delimiters rainbow-delimiters
@ -1282,6 +1465,7 @@ in {
treesitter treesitter
trim trim
trouble trouble
# twilight # NOTE: Don't like it
ufo ufo
which-key which-key
yanky yanky

View File

@ -1,3 +1,6 @@
-- Make Lazy window border rounded
require("lazy.core.config").options.ui.border = "rounded"
-- Toggle inline diagnostics and show border -- Toggle inline diagnostics and show border
vim.g.enable_inline_diagnostics = false vim.g.enable_inline_diagnostics = false
vim.diagnostic.config({ vim.diagnostic.config({
@ -34,3 +37,16 @@ vim.api.nvim_create_user_command("LspInspect", function()
end, { end, {
desc = "Print LSP server configuration", desc = "Print LSP server configuration",
}) })
-- Toggle linting
vim.g.disable_autolint = false
vim.api.nvim_create_user_command("ToggleAutoLint", function()
vim.g.disable_autolint = not vim.g.disable_autolint
if vim.g.disable_autolint then
-- vim.diagnostic.reset(vim.api.nvim_get_current_buf())
vim.diagnostic.reset() -- Reset for all buffers
end
require("notify")((vim.g.disable_autolint and "Disabled" or "Enabled") .. " autolint-on-save")
end, {
desc = "Toggle autolint-on-save",
})

View File

@ -1,25 +1,38 @@
function(props) function(props)
local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
if filename == "" then -- local filename = vim.fn.fnamemodify(vim.api.nvim_buf_get_name(props.buf), ":t")
filename = "[No Name]" -- if filename == "" then
end -- filename = "[No Name]"
local ft_icon, ft_color = devicons.get_icon_color(filename) -- end
local modified = vim.bo[props.buf].modified
local res = { -- local helpers = require("incline.helpers")
ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "", -- local devicons = require("nvim-web-devicons")
" ",
{ filename, gui = modified and "bold,italic" or "bold" }, -- local ft_icon, ft_color = devicons.get_icon_color(filename)
guibg = "#44406e", -- local modified = vim.bo[props.buf].modified
} -- local result = {
-- ft_icon and { " ", ft_icon, " ", guibg = ft_color, guifg = helpers.contrast_color(ft_color) } or "",
-- " ",
-- { filename, gui = modified and "bold,italic" or "bold" },
-- guibg = "#44406e",
-- }
-- Just print the breadcrumbs, skip the filename for now
local result = {}
-- TODO: This code doesn't respect navic's max_depth, because get_data is used
if props.focused then if props.focused then
local navic = require("nvim-navic")
local bgColor = "Black"
for _, item in ipairs(navic.get_data(props.buf) or {}) do for _, item in ipairs(navic.get_data(props.buf) or {}) do
table.insert(res, { table.insert(result, {
{ " > ", group = "NavicSeparator" }, { " > ", group = "NavicSeparator", guibg = bgColor },
{ item.icon, group = "NavicIcons" .. item.type }, { item.icon, group = "NavicIcons" .. item.type, guibg = bgColor },
{ item.name, group = "NavicText" }, { item.name, group = "NavicText", guibg = bgColor },
}) })
end end
end end
table.insert(res, " ")
return res table.insert(result, " ")
return result
end end

View File

@ -1,5 +1,6 @@
{...}: let {...}: let
no-leader = [ no-leader = [
# Cursor movement
{ {
mode = "n"; mode = "n";
key = "j"; key = "j";
@ -29,6 +30,7 @@
options.expr = true; options.expr = true;
} }
# Window resize
{ {
mode = "n"; mode = "n";
key = "<C-h>"; key = "<C-h>";
@ -54,6 +56,7 @@
options.desc = "Increase window height"; options.desc = "Increase window height";
} }
# Move lines
{ {
mode = "n"; mode = "n";
key = "<M-j>"; key = "<M-j>";
@ -91,26 +94,21 @@
options.desc = "Move line up"; options.desc = "Move line up";
} }
# Save buffers
{ {
mode = "n"; mode = ["n" "i" "v"];
key = "<C-s>"; key = "<C-s>";
action = "<cmd>w<cr>"; action = "<cmd>w<cr>";
options.desc = "Save current buffer"; options.desc = "Save current buffer";
} }
{ {
mode = "n"; mode = ["n" "i" "v"];
key = "<C-S-s>"; key = "<C-S-s>";
action = "<cmd>wa<cr>"; action = "<cmd>wa<cr>";
options.desc = "Save all buffers"; options.desc = "Save all buffers";
} }
{ # Indentation
mode = "v";
key = ";";
action = "<Esc>";
options.desc = "Exit visual mode";
}
{ {
mode = "v"; mode = "v";
key = "<"; key = "<";
@ -142,6 +140,7 @@
options.desc = "Indent (IntelliTab)"; options.desc = "Indent (IntelliTab)";
} }
# Centered jumping
{ {
mode = "n"; mode = "n";
key = "<C-d>"; key = "<C-d>";
@ -167,6 +166,7 @@
options.desc = "Previous match (centered)"; options.desc = "Previous match (centered)";
} }
# Delete word
{ {
mode = "i"; mode = "i";
key = "<C-BS>"; key = "<C-BS>";
@ -180,6 +180,7 @@
options.desc = "Delete previous word"; # TODO: Breaks backspace <C-v><S-i> multiline cursor? options.desc = "Delete previous word"; # TODO: Breaks backspace <C-v><S-i> multiline cursor?
} }
# Clipboard
{ {
mode = "i"; mode = "i";
key = "<C-S-v>"; key = "<C-S-v>";
@ -199,6 +200,21 @@
options.desc = "Copy to clipboard"; options.desc = "Copy to clipboard";
} }
# Flash/Search
{
mode = "n";
key = "s"; # TODO: Key doesn't work
action = "<cmd>lua require('flash').jump()<cr>";
options.desc = "Flash jump";
}
{
mode = "n";
key = "S"; # TODO: Key doesn't work
action = "<cmd>lua require('flash').treesitter()<cr>";
options.desc = "Flash treesitter";
}
# Various
{ {
mode = "n"; mode = "n";
key = "<C-h>"; key = "<C-h>";
@ -219,6 +235,13 @@
action = "<cmd>Telescope current_buffer_fuzzy_find<cr>"; action = "<cmd>Telescope current_buffer_fuzzy_find<cr>";
options.desc = "Find in current buffer"; options.desc = "Find in current buffer";
} }
{
mode = "v";
key = ";";
action = "<Esc>";
options.desc = "Exit visual mode";
}
]; ];
leader = [ leader = [
@ -484,6 +507,13 @@
options.desc = "Toggle autoformat-on-save"; options.desc = "Toggle autoformat-on-save";
} }
{
mode = "n";
key = "<leader>tl";
action = "<cmd>ToggleAutoLint<cr>";
options.desc = "Toggle autolint-on-save";
}
{ {
mode = "n"; mode = "n";
key = "<leader>tD"; key = "<leader>tD";