Neovim, switch to nixvim and mono file
This merges all the different files into one app.nix using nixvim instead of the manual home-manager nvim management. Behavior should be almost unchanged, with the following changes: - Plugins now have defaults for my own personal sane default experience - The highlighted line is now 80 instead of 81 - Treesitter plugins may not be integrated correctly
This commit is contained in:
parent
dcc7b97cfc
commit
8786575166
6 changed files with 177 additions and 387 deletions
|
|
@ -14,156 +14,212 @@
|
|||
catppuccin.enable = lib.mkEnableOption "Enables catppuccin theme";
|
||||
};
|
||||
plugins = {
|
||||
comments.enable = lib.mkEnableOption "Enables nvim-comment";
|
||||
fugitive.enable = lib.mkEnableOption "Enables git-fugitive";
|
||||
lualine.enable = lib.mkEnableOption "Enables lualine";
|
||||
luasnip.enable = lib.mkEnableOption "Enables luasnip snippets";
|
||||
nvimcmp.enable = lib.mkEnableOption "Enables nvim completion";
|
||||
comments.enable = lib.mkOption { default = true; };
|
||||
fugitive.enable = lib.mkOption { default = true; };
|
||||
lualine.enable = lib.mkOption { default = true; };
|
||||
luasnip.enable = lib.mkOption { default = false; };
|
||||
nvimcmp.enable = lib.mkOption { default = true; };
|
||||
telescope = {
|
||||
enable = lib.mkEnableOption "Enables telescope";
|
||||
fzf.enable = lib.mkEnableOption "Enables telescope-fzf";
|
||||
enable = lib.mkOption { default = true; };
|
||||
fzf.enable = lib.mkOption { default = true; };
|
||||
};
|
||||
treesitter.enable = lib.mkEnableOption "Enables treesitter";
|
||||
wiki.enable = lib.mkEnableOption "Enables a wiki";
|
||||
treesitter.enable = lib.mkOption { default = true; };
|
||||
wiki.enable = lib.mkOption { default = false; };
|
||||
};
|
||||
};
|
||||
|
||||
imports = [
|
||||
./plugin/lsp.nix
|
||||
./plugin/nvimcmp.nix
|
||||
./plugin/telescope.nix
|
||||
./plugin/treesitter.nix
|
||||
];
|
||||
|
||||
config = lib.mkIf config.neovim.enable {
|
||||
home.sessionVariables = {
|
||||
EDITOR = "nvim";
|
||||
VISUAL = "nvim";
|
||||
};
|
||||
|
||||
programs.neovim = {
|
||||
programs.nixvim = {
|
||||
enable = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
|
||||
extraLuaConfig = ''
|
||||
${builtins.readFile ./options.lua}
|
||||
'';
|
||||
globals = {
|
||||
mapleader = " ";
|
||||
maplocalleader = " ";
|
||||
rust_recommended_style = 0;
|
||||
};
|
||||
|
||||
extraPackages = with pkgs; [
|
||||
(lib.mkIf config.neovim.languages.c.enable libclang)
|
||||
(lib.mkIf config.neovim.languages.go.enable gopls)
|
||||
(lib.mkIf config.neovim.languages.nix.enable nil)
|
||||
(lib.mkIf config.neovim.languages.rust.enable rust-analyzer)
|
||||
opts = {
|
||||
list = true;
|
||||
updatetime = 750;
|
||||
|
||||
tabstop = 2;
|
||||
softtabstop = 0;
|
||||
shiftwidth = 2;
|
||||
smarttab = true;
|
||||
expandtab = true;
|
||||
|
||||
colorcolumn = "81";
|
||||
showmatch = true;
|
||||
number = true;
|
||||
relativenumber = true;
|
||||
|
||||
swapfile = false;
|
||||
backup = false;
|
||||
undofile = true;
|
||||
undodir = "${config.xdg.configHome}/nvim/undodir";
|
||||
|
||||
smartcase = true;
|
||||
};
|
||||
|
||||
keymaps = [
|
||||
{
|
||||
key = "<leader>d";
|
||||
mode = "n";
|
||||
action = "vim.diagnostic.open_float()";
|
||||
}
|
||||
# -- Easy Split Navigation
|
||||
# -- nnoremap <C-J> <C-W><C-J>
|
||||
# -- nnoremap <C-K> <C-W><C-K>
|
||||
# -- nnoremap <C-L> <C-W><C-L>
|
||||
# -- nnoremap <C-H> <C-W><C-H>
|
||||
#
|
||||
# -- Easy copy and pasting to external programs
|
||||
# -- map <C-y> "+yy
|
||||
# -- map <C-p> "+P
|
||||
];
|
||||
};
|
||||
|
||||
# Additional packages are added through imports
|
||||
plugins = let
|
||||
lopts = lib.lists.optionals;
|
||||
cfgp = config.neovim.plugins;
|
||||
cfgl = config.neovim.languages;
|
||||
cfgt = config.neovim.themes;
|
||||
programs.nixvim.colorschemes = with config.neovim.themes; {
|
||||
catppuccin = lib.mkIf catppuccin.enable {
|
||||
enable = true;
|
||||
flavour = "mocha";
|
||||
integrations.vimwiki = lib.mkIf wiki.enable true;
|
||||
};
|
||||
};
|
||||
|
||||
comments = lopts cfgp.comments.enable (with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = comment-nvim;
|
||||
type = "lua";
|
||||
config = "require(\"Comment\").setup()";
|
||||
}
|
||||
]);
|
||||
programs.nixvim.plugins = with config.neovim.plugins; {
|
||||
comment.enable = comments.enable;
|
||||
|
||||
fugitive = lopts cfgp.fugitive.enable (with pkgs.vimPlugins; [
|
||||
vim-fugitive
|
||||
]);
|
||||
fugitive.enable = fugitive.enable;
|
||||
|
||||
luasnip-pkg = lopts cfgp.luasnip.enable (with pkgs.vimPlugins; [
|
||||
luasnip
|
||||
friendly-snippets
|
||||
(lib.mkIf cfgp.nvimcmp.enable cmp_luasnip)
|
||||
]);
|
||||
lualine = lib.mkIf lualine.enable {
|
||||
enable = true;
|
||||
icons_enabled = true;
|
||||
};
|
||||
web-devicons.enable = lualine.enable;
|
||||
|
||||
lualine = lopts cfgp.lualine.enable (with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = lualine-nvim;
|
||||
type = "lua";
|
||||
config = ''
|
||||
require("lualine").setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
'' + lib.strings.optionalString cfgt.catppuccin.enable ''
|
||||
theme = "catppuccin"
|
||||
luasnip.enable = luasnip.enable;
|
||||
friendly-snippets.enable = luasnip.enable;
|
||||
|
||||
cmp = {
|
||||
enable = nvimcmp.enable;
|
||||
autoEnableSources = true;
|
||||
settings.sources = [
|
||||
{ name = "nvim_lsp"; }
|
||||
{ name = "path"; }
|
||||
{ name = "buffer"; }
|
||||
] ++ lib.optional luasnip.enable { name = "cmp-luasnip"; };
|
||||
|
||||
mapping = {
|
||||
"<C-Space>" = "cmp.mapping.complete {}";
|
||||
"<CR>" = "cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
}";
|
||||
"<Tab>" = {
|
||||
actions = ''
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
'' + lib.optionalString luasnip.enable ''
|
||||
elseif luasnip.expand_or_locally_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
'' + ''
|
||||
}
|
||||
}
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
nvim-web-devicons
|
||||
]);
|
||||
|
||||
nix-pkg = lopts cfgl.nix.enable (with pkgs.vimPlugins; [
|
||||
vim-nix
|
||||
]);
|
||||
|
||||
rust-pkg = lopts cfgl.rust.enable (with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = rustaceanvim;
|
||||
type = "lua";
|
||||
config = ''
|
||||
vim.g.rust_recommended_style = 0
|
||||
'';
|
||||
}
|
||||
]);
|
||||
|
||||
go-pkg = lopts cfgl.go.enable (with pkgs.vimPlugins; [
|
||||
go-nvim
|
||||
]);
|
||||
|
||||
typescript-pkg = lopts cfgl.typescript.enable (with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = typescript-tools-nvim;
|
||||
type = "lua";
|
||||
config = ''
|
||||
require("typescript-tools").setup {}
|
||||
'';
|
||||
}
|
||||
]);
|
||||
|
||||
catppuccin-pkg = lopts cfgt.catppuccin.enable (with pkgs.vimPlugins; [
|
||||
{
|
||||
plugin = catppuccin-nvim;
|
||||
type = "lua";
|
||||
config = ''
|
||||
vim.cmd.colorscheme "catppuccin-mocha"
|
||||
require('catppuccin').setup({
|
||||
integrations = {
|
||||
'' + lib.strings.optionalString cfgp.wiki.enable ''
|
||||
vimwiki = true
|
||||
modes = [ "i" "s" ];
|
||||
};
|
||||
"<S-Tab>" = {
|
||||
actions = ''
|
||||
function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
'' + lib.optionalString luasnip.enable ''
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
'' + ''
|
||||
}
|
||||
})
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
]);
|
||||
modes = [ "i" "s" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
wiki = lopts cfgp.wiki.enable (with pkgs.vimPlugins; [
|
||||
telescope = {
|
||||
enable = telescope.enable;
|
||||
keymaps = {
|
||||
"<leader>ff" = "find_files";
|
||||
"<leader>fg" = "git_files";
|
||||
};
|
||||
extensions = {
|
||||
fzf = lib.mkIf telescope.fzf.enable {
|
||||
enable = true;
|
||||
fuzzy = true;
|
||||
override_generic_sorter = true;
|
||||
override_file_sorter = true;
|
||||
case_mode = "smart_case";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
treesitter = {
|
||||
enable = treesitter.enable;
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
folding.enable = true;
|
||||
};
|
||||
|
||||
vimwiki = {
|
||||
enable = wiki.enable;
|
||||
list = [
|
||||
{
|
||||
plugin = vimwiki;
|
||||
type = "lua";
|
||||
config = ''
|
||||
vim.g.vimwiki_list = {
|
||||
{
|
||||
path = '${config.xdg.userDirs.documents}/wiki',
|
||||
links_space_char = '_',
|
||||
ext = '.md',
|
||||
syntax = 'markdown',
|
||||
}
|
||||
}
|
||||
'';
|
||||
path = "${config.xdg.userDirs.documents}/wiki";
|
||||
links_space_char = "_";
|
||||
ext = ".md";
|
||||
syntax = "markdown";
|
||||
}
|
||||
]);
|
||||
in comments ++ fugitive ++ luasnip-pkg ++ lualine ++ nix-pkg ++ rust-pkg
|
||||
++ go-pkg ++ wiki ++ catppuccin-pkg ++ typescript-pkg;
|
||||
];
|
||||
};
|
||||
|
||||
nvim-lspconfig.enable = true;
|
||||
nix.enable = config.neovim.languages.nix.enable;
|
||||
rustaceanvim.enable = config.neovim.languages.rust.enable;
|
||||
typsecript-tools.enable = config.neovim.languages.typescript.enable;
|
||||
};
|
||||
|
||||
programs.nixvim.lsp = {
|
||||
enable = true;
|
||||
servers = with config.neovim.languages; {
|
||||
clangd.enable = c.enable;
|
||||
gopls.enable = go.enable;
|
||||
nil_ls.enable = nix.enable;
|
||||
rust_analyzer.enable = rust.enable;
|
||||
tsserver.enable = typescript.enable;
|
||||
};
|
||||
keymaps = [
|
||||
{ key = "gd"; lspBufAction = "definition"; }
|
||||
{ key = "gD"; lspBufAction = "declaration"; }
|
||||
{ key = "gi"; lspBufAction = "implementation"; }
|
||||
{ key = "gt"; lspBufAction = "type_definition"; }
|
||||
{ key = "K"; lspBufAction = "hover"; }
|
||||
] ++ lib.optional config.neovim.plugins.telescope.enable {
|
||||
key = "gr";
|
||||
action = config.lib.nixvim.mkRaw
|
||||
"require('telescope.builtin').lsp_references";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue