testing nixvim

This commit is contained in:
cnst
2024-07-14 19:22:54 +02:00
parent e4d12360ba
commit 996a3c64d2
43 changed files with 892 additions and 59 deletions

View File

@@ -0,0 +1,27 @@
{
programs.nixvim.autoCmd = [
# Vertically center document when entering insert mode
{
event = "InsertEnter";
command = "norm zz";
}
# Open help in a vertical split
{
event = "FileType";
pattern = "help";
command = "wincmd L";
}
# Enable spellcheck for some filetypes
{
event = "FileType";
pattern = [
"tex"
"latex"
"markdown"
];
command = "setlocal spell spelllang=en,fr";
}
];
}

View File

@@ -0,0 +1,55 @@
{
programs.nixvim = {
opts.completeopt = ["menu" "menuone" "noselect"];
plugins = {
luasnip.enable = true;
lspkind = {
enable = true;
cmp = {
enable = true;
menu = {
nvim_lsp = "[LSP]";
nvim_lua = "[api]";
path = "[path]";
luasnip = "[snip]";
buffer = "[buffer]";
neorg = "[neorg]";
};
};
};
cmp = {
enable = true;
settings = {
snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end";
mapping = {
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<C-e>" = "cmp.mapping.close()";
"<Tab>" = "cmp.mapping(cmp.mapping.select_next_item(), {'i', 's'})";
"<S-Tab>" = "cmp.mapping(cmp.mapping.select_prev_item(), {'i', 's'})";
"<CR>" = "cmp.mapping.confirm({ select = true })";
};
sources = [
{name = "path";}
{name = "nvim_lsp";}
{name = "luasnip";}
{
name = "buffer";
# Words from other open buffers can also be suggested.
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
}
{name = "neorg";}
];
};
};
};
};
}

View File

@@ -1,62 +1,23 @@
{pkgs, ...}: let
treesitterWithGrammars = pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [
p.bash
p.comment
p.css
p.dockerfile
p.fish
p.gitattributes
p.gitignore
p.go
p.gomod
p.gowork
p.hcl
p.javascript
p.jq
p.json5
p.json
p.lua
p.make
p.markdown
p.nix
p.python
p.rust
p.toml
p.typescript
p.vue
p.yaml
]);
{inputs, ...}: {
imports = [
inputs.nixvim.homeManagerModules.nixvim
./autocommands.nix
./completion.nix
./keymappings.nix
./options.nix
./plugins
./todo.nix
];
treesitter-parsers = pkgs.symlinkJoin {
name = "treesitter-parsers";
paths = treesitterWithGrammars.dependencies;
};
in {
programs.neovim = {
home.shellAliases.v = "nvim";
programs.nixvim = {
enable = true;
defaultEditor = true;
package = pkgs.neovim-unwrapped;
viAlias = true;
vimAlias = true;
coc.enable = false;
withNodeJs = true;
#package = inputs.neovim-nightly-overlay.packages.${pkgs.system}.default;
plugins = [
treesitterWithGrammars
];
};
home.file."./.config/nvim/" = {
source = ./nvim;
recursive = true;
};
home.file."./.config/nvim/lua/cnst/init.lua".text = ''
require("cnst.set")
require("cnst.remap")
vim.opt.runtimepath:append("${treesitter-parsers}")
'';
# Treesitter is configured as a locally developed module in lazy.nvim
# we hardcode a symlink here so that we can refer to it in our lazy config
home.file."./.local/share/nvim/nix/nvim-treesitter/" = {
recursive = true;
source = treesitterWithGrammars;
luaLoader.enable = true;
};
}

View File

@@ -1,64 +0,0 @@
{pkgs, ...}: {
programs.neovim = {
enable = true;
vimAlias = true;
viAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins; [
gruvbox-material-nvim
cmp-buffer
cmp-nvim-lsp
cmp-path
cmp-spell
cmp-treesitter
cmp-vsnip
friendly-snippets
gitsigns-nvim
lightline-vim
lspkind-nvim
neogit
null-ls-nvim
nvim-autopairs
nvim-cmp
nvim-colorizer-lua
nvim-lspconfig
lualine-nvim
nvim-tree-lua
conform-nvim
(nvim-treesitter.withPlugins (_: pkgs.tree-sitter.allGrammars))
plenary-nvim
rainbow-delimiters-nvim
telescope-fzy-native-nvim
telescope-nvim
vim-floaterm
vim-sneak
vim-vsnip
which-key-nvim
];
extraPackages = with pkgs; [gcc ripgrep fd];
extraConfig = let
luaRequire = module:
builtins.readFile (builtins.toString
./config
+ "/${module}.lua");
luaConfig = builtins.concatStringsSep "\n" (map luaRequire [
"init"
"lspconfig"
"nvim-cmp"
"theming"
"treesitter"
"treesitter-textobjects"
"utils"
"which-key"
]);
in ''
lua <<
${luaConfig}
'';
};
}

View File

@@ -0,0 +1,81 @@
{
config,
lib,
...
}: {
programs.nixvim = {
globals = {
mapleader = " ";
maplocalleader = " ";
};
keymaps = let
normal =
lib.mapAttrsToList
(key: action: {
mode = "n";
inherit action key;
})
{
"<Space>" = "<NOP>";
# Esc to clear search results
"<esc>" = ":noh<CR>";
# fix Y behaviour
Y = "y$";
# back and fourth between the two most recent files
"<C-c>" = ":b#<CR>";
# close by Ctrl+x
"<C-x>" = ":close<CR>";
# save by Space+s or Ctrl+s
"<leader>s" = ":w<CR>";
"<C-s>" = ":w<CR>";
# navigate to left/right window
"<leader>h" = "<C-w>h";
"<leader>l" = "<C-w>l";
# Press 'H', 'L' to jump to start/end of a line (first/last character)
L = "$";
H = "^";
# resize with arrows
"<C-Up>" = ":resize -2<CR>";
"<C-Down>" = ":resize +2<CR>";
"<C-Left>" = ":vertical resize +2<CR>";
"<C-Right>" = ":vertical resize -2<CR>";
# move current line up/down
# M = Alt key
"<M-k>" = ":move-2<CR>";
"<M-j>" = ":move+<CR>";
"<leader>rp" = ":!remi push<CR>";
};
visual =
lib.mapAttrsToList
(key: action: {
mode = "v";
inherit action key;
})
{
# better indenting
">" = ">gv";
"<" = "<gv";
"<TAB>" = ">gv";
"<S-TAB>" = "<gv";
# move selected line / block of text in visual mode
"K" = ":m '<-2<CR>gv=gv";
"J" = ":m '>+1<CR>gv=gv";
};
in
config.nixvim.helpers.keymaps.mkKeymaps
{options.silent = true;}
(normal ++ visual);
};
}

View File

@@ -1,24 +0,0 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
vim.g.mapleader = " "
vim.opt.termguicolors = true
vim.opt.guicursor = ""
require("lazy").setup("plugins", {
rocks = { enabled = false },
dev = {
path = "~/.local/share/nvim/nix",
fallback = false,
},
})
require("cnst")

View File

@@ -1,109 +0,0 @@
local map = vim.keymap.set
local close_nvim = function()
vim.cmd("Neotree close")
vim.cmd("qa")
end
--- General
map("n", "+", "/", { desc = "Forward search", nowait = true })
map("n", "-", "?", { desc = "Backward search", nowait = true })
map("n", "<leader>n", "<cmd>enew<cr>", { desc = "New Buffer" })
map({ "n", "t" }, "<A-w>", "<cmd>q<cr>", { desc = "Close Window" })
map({ "n", "t" }, "<C-q>", close_nvim, { desc = "Quick Quit" })
map({ "n", "x" }, ",", ":", { desc = "Enter command mode", nowait = true })
map("n", "<leader>ll", "<cmd>Lazy<cr>", { desc = "Open Lazy" })
map("n", "<leader>mm", "<cmd>Mason<cr>", { desc = "Open Mason" })
map("i", "<C-v>", "<esc>p", { desc = "Paste Clipboard" })
map("n", "<C-c>", "<cmd> %y+ <CR>", { desc = "Copy File to [C]lipboard" })
map({ "i", "x", "n", "s" }, "<C-s>", '<cmd>w "++p"<cr><esc>', { desc = "Save File" })
map(
{ "i", "x", "n", "s" },
"<Esc><C-s>", -- <Alt>+<Control-s>
'<cmd>wa "++p"<cr><esc>',
{ desc = "Save All Files" }
)
map(
"n",
"<leader>cr",
"<cmd>let @+ = expand('%:~:.')<cr><cmd>echo 'Copied path:' @+<cr>",
{ desc = "[C]opy [R]elative Path to Clipboard" }
)
map(
"n",
"<leader>cp",
"<cmd>let @+ = expand('%:p')<cr><cmd>echo 'Copied path:' @+<cr>",
{ desc = "[C]opy Full [P]ath to Clipboard" }
)
map("n", "<leader>gp", ":e <C-r>+<CR>", { desc = "[G]o to [P]ath from Clipboard" })
map("v", ">", ">gv", { desc = "Indent Right" })
map("v", "<", "<gv", { desc = "Indent Left" })
-- Don't copy the replaced text after pasting in visual mode
-- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste
map("x", "p", 'p:let @+=@0<CR>:let @"=@0<CR>', { desc = "Dont copy replaced text", silent = true })
-- Don't reset clipboard after first paste in Visual mode
map("v", "p", "P")
--- Tab motions
-- map('n', '<C-t>s', '<cmd>tab split<cr>', { desc = 'Split Window to New Tab' })
-- map('n', '<C-t>t', '<C-w>T', { desc = 'Maximize Window' })
map("n", "<ESC><C-j>", "<cmd>tabprevious<cr>", { desc = "Previous Tab" })
map("n", "<ESC><C-k>", "<cmd>tabnext<cr>", { desc = "Next Tab" })
map("n", "<leader>tc", "<cmd>tabclose<cr>", { desc = "[T]ab [C]lose" })
map("n", "<leader>te", "<cmd>tabedit<cr>", { desc = "[T]ab [E]dit" })
map("n", "<leader>tn", "<cmd>tabnew<cr>", { desc = "[T]ab [N]ew" })
-- Buffer Motions
-- map('n', '<A-j>', '<cmd>bprevious<cr>', { desc = 'Prev Buffer' })
-- map('n', '<A-k>', '<cmd>bnext<cr>', { desc = 'Next Buffer' })
-- map('n', '<A-c>', '<cmd>bdelete<cr>', { desc = 'Close Buffer' })
--- Debugging
map("n", "<leader>ms", "<cmd>messages<cr>", { desc = "Show Messages" })
map("n", "<leader>mn", "<cmd>Noice<cr>", { desc = "Show Noice Messages" })
map("x", "<M-s>", ":sort<cr>", { desc = "Sort Selection" })
--- Terminal
-- switch between windows
map("t", "<C-h>", "<C-\\><C-N><C-w>h", { desc = "Terminal Window Left" })
map("t", "<C-l>", "<C-\\><C-N><C-w>l", { desc = "Terminal Window Right" })
map("t", "<C-j>", "<C-\\><C-N><C-w>j", { desc = "Terminal Window Down" })
map("t", "<C-k>", "<C-\\><C-N><C-w>k", { desc = "Terminal Window Up" })
map("t", "<C-x>", vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true), { desc = "Escape Terminal Mode" })
-- Better Movements
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- map({ 'n', 'x' }, '<Down>', "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
-- map({ 'n', 'x' }, '<Up>', "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- Move Lines
-- map('n', '<A-j>', '<cmd>m .+1<cr>==', { desc = 'Move Down' })
-- map('n', '<A-k>', '<cmd>m .-2<cr>==', { desc = 'Move Up' })
-- map('i', '<A-j>', '<esc><cmd>m .+1<cr>==gi', { desc = 'Move Down' })
-- map('i', '<A-k>', '<esc><cmd>m .-2<cr>==gi', { desc = 'Move Up' })
-- map('v', '<A-j>', ":m '>+1<cr>gv=gv", { desc = 'Move Down' })
-- map('v', '<A-k>', ":m '<-2<cr>gv=gv", { desc = 'Move Up' })
-- Resize window using <ctrl> arrow keys
map({ "n", "t" }, "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase Window Height" })
map({ "n", "t" }, "<C-Down>", "<cmd>resize -2<cr>", { desc = "Decrease Window Height" })
map({ "n", "t" }, "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease Window Width" })
map({ "n", "t" }, "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase Window Width" })
-- Clear search, diff update and redraw
-- taken from runtime/lua/_editor.lua
map(
"n",
"<leader>ur",
"<Cmd>nohlsearch<Bar>diffupdate<Bar>normal! <C-L><CR>",
{ desc = "Redraw / Clear hlsearch / Diff Update" }
)

View File

@@ -1,84 +0,0 @@
return {
"goolord/alpha-nvim",
event = "VimEnter",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
-- Header
local logo = [[
▄████▄ ███▄ █ ██▓▒██ ██▒ ██▒ █▓ ██▓ ███▄ ▄███▓
▒██▀ ▀█ ██ ▀█ █ ▓██▒▒▒ █ █ ▒░▓██░ █▒▓██▒▓██▒▀█▀ ██▒
▒▓█ ▄ ▓██ ▀█ ██▒▒██▒░░ █ ░ ▓██ █▒░▒██▒▓██ ▓██░
▒▓▓▄ ▄██▒▓██▒ ▐▌██▒░██░ ░ █ █ ▒ ▒██ █░░░██░▒██ ▒██
▒ ▓███▀ ░▒██░ ▓██░░██░▒██▒ ▒██▒ ▒▀█░ ░██░▒██▒ ░██▒
░ ░▒ ▒ ░░ ▒░ ▒ ▒ ░▓ ▒▒ ░ ░▓ ░ ░ ▐░ ░▓ ░ ▒░ ░ ░
░ ▒ ░ ░░ ░ ▒░ ▒ ░░░ ░▒ ░ ░ ░░ ▒ ░░ ░ ░
░ ░ ░ ░ ▒ ░ ░ ░ ░░ ▒ ░░ ░
░ ░ ░ ░ ░ ░ ░ ░ ░
░ ░
]]
dashboard.section.header.val = vim.split(logo, "\n")
-- Buttons
dashboard.section.buttons.val = {
dashboard.button("n", "" .. " New file", "<cmd> ene <BAR> startinsert <cr>"),
dashboard.button("f", "" .. " Find file", "<cmd> Telescope find_files <cr>"),
dashboard.button("g", "" .. " Live grep", "<cmd> Telescope live_grep <cr>"),
dashboard.button("r", "" .. " Recent files", "<cmd> Telescope oldfiles <cr>"),
-- dashboard.button('s', ' ' .. ' Restore Session', "<cmd>lua require('persistence').load()<cr>"),
dashboard.button("s", "" .. " Restore Session", "<cmd>SessionLoad<cr>"),
dashboard.button("l", "󰒲 " .. " Lazy", "<cmd> Lazy <cr>"),
dashboard.button("h", "󱙤 " .. " Check Health", "<cmd>checkhealth<cr>"),
dashboard.button("q", "" .. " Quit", "<cmd> qa <cr>"),
}
for _, button in ipairs(dashboard.section.buttons) do
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
end
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.section.footer.opts.hl = "AlphaFooter"
dashboard.opts.layout[1].val = 8
-- Footer (Lazy statistics)
vim.api.nvim_create_autocmd("User", {
callback = function()
local stats = require("lazy").stats()
local ms = math.floor(stats.startuptime * 100) / 100
dashboard.section.footer.val = "󱐌 Lazy-loaded "
.. stats.loaded
.. "/"
.. stats.count
.. " plugins in "
.. ms
.. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
-- -- Fortune
-- local fortune = ""
-- if vim.fn.executable "fortune" == 1 then
-- local handle = io.popen "fortune"
-- if handle ~= nil then
-- fortune = handle:read "*a"
-- handle:close()
-- end
-- end
-- local buttons = {
-- type = "group",
-- val = {
-- { type = "padding", val = 2 },
-- { type = "text", val = fortune, opts = { position = "center" } },
-- { type = "padding", val = 2 },
-- },
-- position = "center",
-- }
-- dashboard.opts.layout[6] = buttons
dashboard.config.opts.noautocmd = true
alpha.setup(dashboard.config)
end,
}

View File

@@ -1,13 +0,0 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
-- Optional dependency
dependencies = { "hrsh7th/nvim-cmp" },
config = function()
require("nvim-autopairs").setup({})
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end,
}

View File

@@ -1,6 +0,0 @@
return {
"max397574/better-escape.nvim",
config = function()
require("better_escape").setup()
end,
}

View File

@@ -1,3 +0,0 @@
return {
{ "nvim-tree/nvim-web-devicons", opts = {}, lazy = true },
}

View File

@@ -1,9 +0,0 @@
return {
{
"lewis6991/gitsigns.nvim",
lazy = true,
tag = "v0.8.0",
event = { "BufReadPost" },
opts = {},
},
}

View File

@@ -1,5 +0,0 @@
return {
"calops/hmts.nvim",
version = "*",
ft = "nix",
}

View File

@@ -1,11 +0,0 @@
return {
{
"sainnhe/gruvbox-material",
enabled = true,
priority = 1000,
opts = {},
config = function()
vim.cmd([[colorscheme gruvbox-material]])
end,
},
}

View File

@@ -1,144 +0,0 @@
return {
{
"VonHeikemen/lsp-zero.nvim",
event = { "BufReadPre", "BufNewFile" },
branch = "v2.x",
dependencies = {
-- LSP Support
{ "neovim/nvim-lspconfig" },
{ "williamboman/mason.nvim" },
{ "williamboman/mason-lspconfig.nvim" },
-- Autocompletion
{ "hrsh7th/nvim-cmp" },
{ "hrsh7th/cmp-buffer" },
{ "hrsh7th/cmp-path" },
{ "saadparwaiz1/cmp_luasnip" },
{ "hrsh7th/cmp-nvim-lsp" },
{ "hrsh7th/cmp-nvim-lua" },
-- Snippets
{ "L3MON4D3/LuaSnip" },
-- Snippet Collection (Optional)
{ "rafamadriz/friendly-snippets" },
{ "onsails/lspkind.nvim" },
},
config = function()
local lsp = require("lsp-zero")
lsp.preset("recommended")
-- don't initialize this language server
-- we will use rust-tools to setup rust_analyzer
lsp.skip_server_setup({ "rust_analyzer" })
local cmp = require("cmp")
local cmp_select = { behavior = cmp.SelectBehavior.Select }
local cmp_mappings = lsp.defaults.cmp_mappings({
["<C-p>"] = cmp.mapping.select_prev_item(cmp_select),
["<C-n>"] = cmp.mapping.select_next_item(cmp_select),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<C-Space>"] = cmp.mapping.complete(),
})
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
local lspkind = require("lspkind")
lsp.setup_nvim_cmp({
mapping = cmp_mappings,
formatting = {
format = lspkind.cmp_format({
mode = "symbol_text",
maxwidth = 75,
ellipsis_char = "...",
symbol_map = {
Copilot = "",
},
}),
},
sources = {
{ name = "nvim_lsp" },
{ name = "buffer" },
{ name = "copilot" },
{ name = "path" },
{ name = "luasnip" },
},
})
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.nu = {
install_info = {
url = "https://github.com/nushell/tree-sitter-nu",
files = { "src/parser.c" },
branch = "main",
},
filetype = "nu",
}
local format_sync_grp = vim.api.nvim_create_augroup("Format", {})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*",
callback = function()
vim.lsp.buf.format({ timeout_ms = 200 })
end,
group = format_sync_grp,
})
lsp.on_attach(function(client, bufnr)
local opts = { buffer = bufnr, remap = false }
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts)
vim.keymap.set("n", "<leader>vws", vim.lsp.buf.workspace_symbol, opts)
vim.keymap.set("n", "<leader>vd", vim.diagnostic.open_float, opts)
vim.keymap.set("n", "[d", vim.diagnostic.goto_next, opts)
vim.keymap.set("n", "]d", vim.diagnostic.goto_prev, opts)
vim.keymap.set("n", "<leader>vca", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>a", vim.lsp.buf.code_action, opts)
vim.keymap.set("n", "<leader>vrr", vim.lsp.buf.references, opts)
vim.keymap.set("n", "<leader>vrn", vim.lsp.buf.rename, opts)
vim.keymap.set("i", "<C-h>", vim.lsp.buf.signature_help, opts)
end)
lsp.configure("nil_ls", {
settings = {
["nil"] = {
formatting = { command = { "nixpkgs-fmt" } },
},
},
})
lsp.configure("nushell", {
command = { "nu", "--lsp" },
filetypes = { "nu" },
root_dir = require("lspconfig.util").find_git_ancestor,
singe_file_support = true,
})
lsp.configure("volar", {
filetypes = { "typescript", "javascript", "javascriptreact", "typescriptreact", "vue", "json" },
})
lsp.set_server_config({
on_init = function(client)
client.server_capabilities.semanticTokensProvider = nil
end,
})
lsp.nvim_workspace()
lsp.setup()
vim.diagnostic.config({
virtual_text = true,
signs = true,
update_in_insert = true,
underline = true,
severity_sort = false,
float = true,
})
end,
},
}

View File

@@ -1,41 +0,0 @@
local go_package = function()
for _, line in ipairs(vim.api.nvim_buf_get_lines(0, 0, -1, true)) do
if line:match("^package ") then
return "" .. string.sub(line, 9)
end
end
return ""
end
return {
{
"nvim-lualine/lualine.nvim",
event = "VeryLazy",
dependencies = { "nvim-tree/nvim-web-devicons", optional = true },
opts = {
options = {
theme = "dracula",
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = {
{
go_package,
cond = function()
return vim.bo.filetype == "go"
end,
},
{ "filename" },
},
lualine_x = {
"encoding",
"fileformat",
"filetype",
},
lualine_y = { "progress" },
lualine_z = { "location" },
},
},
},
}

View File

@@ -1,53 +0,0 @@
return {
{
"nvim-neo-tree/neo-tree.nvim",
version = "*",
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons", -- optional, but recommended
"MunifTanjim/nui.nvim",
},
event = { "BufReadPost", "BufNewFile" },
cmd = { "Neotree" },
opts = {
close_if_last_window = true,
window = {
mappings = {
["l"] = "open",
["h"] = "open_split",
-- TODO: `v` is for select. Find another key for vsplit
-- ['v'] = 'open_vsplit',
},
},
filesystem = {
follow_current_file = { enabled = true },
},
},
keys = {
{ "<C-n>", "<CMD>Neotree toggle<CR>", mode = { "n", "x", "t" }, desc = "Toggle [N]eoTree", nowait = true },
-- {
-- '<C-b>',
-- '<CMD>Neotree toggle buffers<CR>',
-- mode = { 'n', 'x', 't' },
-- desc = 'Toggle Neotree [B]uffers',
-- nowait = true,
-- },
{
"<C-f>",
"<CMD>Neotree toggle position=current<CR>",
mode = { "n", "x" },
desc = "Toggle [F]ull NeoTree",
nowait = true,
},
},
},
-- file operations using built-in LSP
{
"antosha417/nvim-lsp-file-operations",
config = true,
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-neo-tree/neo-tree.nvim",
},
},
}

View File

@@ -1,10 +0,0 @@
return {
{
"rcarriga/nvim-notify",
lazy = true,
opts = {
render = "compact",
background_colour = "#000000",
},
},
}

View File

@@ -1,47 +0,0 @@
return {
{
"mrcjkb/rustaceanvim",
version = "^3",
event = { "BufReadPost *.rs" },
keys = {
{
"<Leader>a",
mode = "n",
function()
vim.cmd.RustLsp("codeAction")
end,
{ buffer = vim.api.nvim_get_current_buf() },
desc = "LSP Code Action",
},
},
config = function()
vim.g.rustaceanvim = {
tools = {
inlay_hints = {
auto = false,
highlight = "Debug",
},
hover_actions = {
auto_focus = true,
},
},
server = {
settings = {
["rust-analyzer"] = {
checkOnSave = {
enable = true,
command = "clippy",
},
cargo = {
allFeatures = true,
},
},
},
on_attach = function(client, _)
client.server_capabilities.semanticTokensProvider = nil
end,
},
}
end,
},
}

View File

@@ -1,68 +0,0 @@
return {
{
"nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = {
"nvim-lua/plenary.nvim",
{
"nvim-telescope/telescope-file-browser.nvim",
event = "VeryLazy",
dependencies = {
"nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
},
},
},
-- stylua: ignore
keys = {
{
"<leader>pf",
mode = "n",
function() require("telescope.builtin").find_files() end,
desc = "telescope find files"
},
{
"<C-p>",
mode = "n",
function() require("telescope.builtin").git_files() end,
desc = "telescope find files"
},
{
"<leader>ps",
mode = "n",
function()
require("telescope.builtin").live_grep()
end,
desc = "telescope grep string"
},
{
"<leader>pt",
mode = "n",
function()
require("telescope.builtin").treesitter()
end,
desc = "telescope treesitter"
},
{
"<leader>pb",
mode = "n",
function() require("telescope.builtin").buffers() end,
desc = "telescope buffers"
},
},
config = function()
local opts = {
extensions = {
file_browser = {
respect_gitignore = false,
hijack_netrw = true,
hidden = true,
},
},
}
require("telescope").setup(opts)
require("telescope").load_extension("file_browser")
end,
},
}

View File

@@ -1,25 +0,0 @@
return {
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
main = "nvim-treesitter.configs",
dev = true,
opts = {
-- autotag = {
-- enable = true
-- },
highlight = {
-- `false` will disable the whole extension
enable = true,
additional_vim_regex_highlighting = false,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = "<CR>",
node_incremental = "<CR>",
scope_incremental = "<S-CR>",
node_decremental = "<BS>",
},
},
},
}

View File

@@ -1,7 +0,0 @@
return {
{
"folke/which-key.nvim",
event = "VeryLazy",
opts = {},
},
}

View File

@@ -0,0 +1,63 @@
{
programs.nixvim = {
globals = {
# Disable useless providers
loaded_ruby_provider = 0; # Ruby
loaded_perl_provider = 0; # Perl
loaded_python_provider = 0; # Python 2
};
clipboard = {
# Use system clipboard
register = "unnamedplus";
providers.wl-copy.enable = true;
};
opts = {
updatetime = 100; # Faster completion
# Line numbers
relativenumber = false; # Relative line numbers
number = true; # Display the absolute line number of the current line
hidden = true; # Keep closed buffer open in the background
mouse = "a"; # Enable mouse control
mousemodel = "extend"; # Mouse right-click extends the current selection
splitbelow = true; # A new window is put below the current one
splitright = true; # A new window is put right of the current one
swapfile = false; # Disable the swap file
modeline = true; # Tags such as 'vim:ft=sh'
modelines = 100; # Sets the type of modelines
undofile = true; # Automatically save and restore undo history
incsearch = true; # Incremental search: show match for partly typed search command
inccommand = "split"; # Search and replace: preview changes in quickfix list
ignorecase = true; # When the search query is lower-case, match both lower and upper-case
# patterns
smartcase = true; # Override the 'ignorecase' option if the search pattern contains upper
# case characters
scrolloff = 8; # Number of screen lines to show around the cursor
cursorline = false; # Highlight the screen line of the cursor
cursorcolumn = false; # Highlight the screen column of the cursor
signcolumn = "yes"; # Whether to show the signcolumn
colorcolumn = "100"; # Columns to highlight
laststatus = 3; # When to use a status line for the last window
fileencoding = "utf-8"; # File-content encoding for the current buffer
termguicolors = true; # Enables 24-bit RGB color in the |TUI|
spell = false; # Highlight spelling mistakes (local to window)
wrap = false; # Prevent text from wrapping
# Tab options
tabstop = 4; # Number of spaces a <Tab> in the text stands for (local to buffer)
shiftwidth = 4; # Number of spaces used for each step of (auto)indent (local to buffer)
expandtab = true; # Expand <Tab> to spaces in Insert mode (local to buffer)
autoindent = true; # Do clever autoindenting
textwidth = 0; # Maximum width of text that is being inserted. A longer line will be
# broken after white space to get this width.
# Folding
foldlevel = 99; # Folds with a level higher than this number will be closed
};
};
}

View File

@@ -0,0 +1,10 @@
{
programs.nixvim.plugins.barbar = {
enable = true;
keymaps = {
next.key = "<TAB>";
previous.key = "<S-TAB>";
close.key = "<C-w>";
};
};
}

View File

@@ -0,0 +1,10 @@
{
programs.nixvim.plugins.comment = {
enable = true;
settings = {
opleader.line = "<C-b>";
toggler.line = "<C-b>";
};
};
}

View File

@@ -0,0 +1,56 @@
{
imports = [
./barbar.nix
./comment.nix
./efm.nix
./floaterm.nix
./harpoon.nix
./lsp.nix
./lualine.nix
./markdown-preview.nix
./neorg.nix
./neo-tree.nix
./startify.nix
./tagbar.nix
./telescope.nix
./treesitter.nix
./vimtex.nix
];
programs.nixvim = {
colorschemes.gruvbox.enable = true;
plugins = {
gitsigns = {
enable = true;
settings.signs = {
add.text = "+";
change.text = "~";
};
};
nvim-autopairs.enable = true;
nvim-colorizer = {
enable = true;
userDefaultOptions.names = false;
};
oil.enable = true;
trim = {
enable = true;
settings = {
highlight = true;
ft_blocklist = [
"checkhealth"
"floaterm"
"lspinfo"
"neo-tree"
"TelescopePrompt"
];
};
};
};
};
}

View File

@@ -0,0 +1,22 @@
{
programs.nixvim.plugins = {
lsp.servers.efm = {
enable = true;
extraOptions.init_options = {
documentFormatting = true;
documentRangeFormatting = true;
hover = true;
documentSymbol = true;
codeAction = true;
completion = true;
};
};
lsp-format = {
enable = true;
lspServersToEnable = ["efm"];
};
efmls-configs.enable = true;
};
}

View File

@@ -0,0 +1,12 @@
{
programs.nixvim.plugins.floaterm = {
enable = true;
width = 0.8;
height = 0.8;
title = "";
keymaps.toggle = "<leader>,";
};
}

View File

@@ -0,0 +1,20 @@
{
programs.nixvim = {
plugins.harpoon = {
enable = true;
keymapsSilent = true;
keymaps = {
addFile = "<leader>a";
toggleQuickMenu = "<C-e>";
navFile = {
"1" = "<C-j>";
"2" = "<C-k>";
"3" = "<C-l>";
"4" = "<C-m>";
};
};
};
};
}

View File

@@ -0,0 +1,33 @@
{
programs.nixvim = {
plugins = {
lsp = {
enable = true;
keymaps = {
silent = true;
diagnostic = {
# Navigate in diagnostics
"<leader>k" = "goto_prev";
"<leader>j" = "goto_next";
};
lspBuf = {
gd = "definition";
gD = "references";
gt = "type_definition";
gi = "implementation";
K = "hover";
"<F2>" = "rename";
};
};
servers = {
clangd.enable = true;
lua-ls.enable = true;
texlab.enable = true;
};
};
};
};
}

View File

@@ -0,0 +1,46 @@
{
programs.nixvim.plugins.lualine = {
enable = true;
globalstatus = true;
# +-------------------------------------------------+
# | A | B | C X | Y | Z |
# +-------------------------------------------------+
sections = {
lualine_a = ["mode"];
lualine_b = ["branch"];
lualine_c = ["filename" "diff"];
lualine_x = [
"diagnostics"
# Show active language server
{
name.__raw = ''
function()
local msg = ""
local buf_ft = vim.api.nvim_buf_get_option(0, 'filetype')
local clients = vim.lsp.get_active_clients()
if next(clients) == nil then
return msg
end
for _, client in ipairs(clients) do
local filetypes = client.config.filetypes
if filetypes and vim.fn.index(filetypes, buf_ft) ~= -1 then
return client.name
end
end
return msg
end
'';
icon = "";
color.fg = "#ffffff";
}
"encoding"
"fileformat"
"filetype"
];
};
};
}

View File

@@ -0,0 +1,20 @@
{
programs.nixvim = {
plugins.markdown-preview = {
enable = true;
settings = {
auto_close = false;
theme = "dark";
};
};
files."after/ftplugin/markdown.lua".keymaps = [
{
mode = "n";
key = "<leader>m";
action = ":MarkdownPreview<cr>";
}
];
};
}

View File

@@ -0,0 +1,22 @@
{
programs.nixvim = {
keymaps = [
{
mode = "n";
key = "<leader>n";
action = ":Neotree action=focus reveal toggle<CR>";
options.silent = true;
}
];
plugins.neo-tree = {
enable = true;
closeIfLastWindow = true;
window = {
width = 30;
autoExpandWidth = true;
};
};
};
}

View File

@@ -0,0 +1,32 @@
{
programs.nixvim.plugins.startify = {
enable = true;
settings = {
custom_header = [
""
" "
" "
" "
" "
" "
" "
];
# When opening a file or bookmark, change to its directory.
change_to_dir = false;
# By default, the fortune header uses ASCII characters, because they work for everyone.
# If you set this option to 1 and your 'encoding' is "utf-8", Unicode box-drawing characters will
# be used instead.
use_unicode = true;
lists = [{type = "dir";}];
files_number = 30;
skiplist = [
"flake.lock"
];
};
};
}

View File

@@ -0,0 +1,17 @@
{
programs.nixvim = {
plugins.tagbar = {
enable = true;
settings.width = 50;
};
keymaps = [
{
mode = "n";
key = "<C-g>";
action = ":TagbarToggle<cr>";
options.silent = true;
}
];
};
}

View File

@@ -0,0 +1,33 @@
{
programs.nixvim = {
plugins.telescope = {
enable = true;
keymaps = {
# Find files using Telescope command-line sugar.
"<leader>ff" = "find_files";
"<leader>fg" = "live_grep";
"<leader>b" = "buffers";
"<leader>fh" = "help_tags";
"<leader>fd" = "diagnostics";
# FZF like bindings
"<C-p>" = "git_files";
"<leader>p" = "oldfiles";
"<C-f>" = "live_grep";
};
settings.defaults = {
file_ignore_patterns = [
"^.git/"
"^.mypy_cache/"
"^__pycache__/"
"^output/"
"^data/"
"%.ipynb"
];
set_env.COLORTERM = "truecolor";
};
};
};
}

View File

@@ -0,0 +1,26 @@
{
programs.nixvim.plugins = {
treesitter = {
enable = true;
nixvimInjections = true;
settings = {
highlight.enable = true;
indent.enable = true;
};
folding = true;
};
treesitter-refactor = {
enable = true;
highlightDefinitions = {
enable = true;
# Set to false if you have an `updatetime` of ~100.
clearOnCursorMove = false;
};
};
hmts.enable = true;
};
}

View File

@@ -0,0 +1,77 @@
{
programs.nixvim = {
plugins.vimtex = {
enable = true;
settings = {
view_method = "zathura";
quickfix_enabled = true;
quickfix_open_on_warning = false;
# Ignore undesired errors and warnings
quickfix_ignore_filters = [
"Underfull"
"Overfull"
"specifier changed to"
"Token not allowed in a PDF string"
];
# TOC settings
toc_config = {
name = "TOC";
layers = ["content" "todo"];
resize = true;
split_width = 50;
todo_sorted = false;
show_help = true;
show_numbers = true;
mode = 2;
};
};
};
files."after/ftplugin/tex.lua".keymaps = [
{
mode = "n";
key = "m";
action = ":VimtexView<cr>";
}
];
autoCmd = [
{
event = ["BufEnter" "BufWinEnter"];
pattern = "*.tex";
command = "set filetype=tex \"| VimtexTocOpen";
}
# Folding
{
event = "FileType";
pattern = ["tex" "latex"];
callback.__raw = ''
function ()
vim.o.foldmethod = 'expr'
vim.o.foldexpr = 'vimtex#fold#level(v:lnum)'
vim.o.foldtext = 'vimtex#fold#text()'
end
'';
}
# Compile on initialization
{
event = "User";
pattern = "VimtexEventInitPost";
callback = "vimtex#compiler#compile";
}
# Cleanup on exit
{
event = "User";
pattern = "VimtexEventQuit";
command = "call vimtex#compiler#clean(0)";
}
];
};
}

View File

@@ -0,0 +1,26 @@
{
programs.nixvim = {
highlight.Todo = {
fg = "Blue";
bg = "Yellow";
};
match.TODO = "TODO";
keymaps = [
{
mode = "n";
key = "<C-t>";
action.__raw = ''
function()
require('telescope.builtin').live_grep({
default_text="TODO",
initial_mode="normal"
})
end
'';
options.silent = true;
}
];
};
}