refactor: move modules to their own dir
This commit is contained in:
parent
dda72854df
commit
addf563bfc
26 changed files with 86 additions and 60 deletions
122
modules/nixvim/augroups.nix
Normal file
122
modules/nixvim/augroups.nix
Normal file
|
@ -0,0 +1,122 @@
|
|||
{
|
||||
config,
|
||||
helpers,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
cfg = config.jhome.nvim;
|
||||
dev = cfg.dev.enable;
|
||||
in
|
||||
{
|
||||
config = {
|
||||
autoGroups = {
|
||||
"highlightOnYank" = { };
|
||||
"lspConfig" = { };
|
||||
"restoreCursorPosition" = { };
|
||||
"terminalConfig" = { };
|
||||
};
|
||||
autoCmd =
|
||||
[
|
||||
{
|
||||
group = "terminalConfig";
|
||||
event = "TermOpen";
|
||||
pattern = "*";
|
||||
callback =
|
||||
# lua
|
||||
mkRaw ''
|
||||
function(args)
|
||||
vim.wo.number = false
|
||||
vim.wo.relativenumber = false
|
||||
end
|
||||
'';
|
||||
}
|
||||
{
|
||||
group = "highlightOnYank";
|
||||
event = "TextYankPost";
|
||||
pattern = "*";
|
||||
callback =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function()
|
||||
vim.highlight.on_yank {
|
||||
higroup = (
|
||||
vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch'
|
||||
),
|
||||
timeout = 200,
|
||||
}
|
||||
end
|
||||
'';
|
||||
}
|
||||
{
|
||||
group = "restoreCursorPosition";
|
||||
event = "BufReadPost";
|
||||
pattern = "*";
|
||||
callback =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function()
|
||||
if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then
|
||||
vim.cmd [[execute "normal! g'\""]]
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
]
|
||||
++ lib.optional dev {
|
||||
group = "lspConfig";
|
||||
event = "LspAttach";
|
||||
pattern = "*";
|
||||
callback =
|
||||
let
|
||||
opts = "noremap = true, buffer = bufnr";
|
||||
in
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function(opts)
|
||||
local bufnr = opts.buf
|
||||
local client = vim.lsp.get_client_by_id(opts.data.client_id)
|
||||
local capabilities = client.server_capabilities
|
||||
-- Set Omnifunc if supported
|
||||
if capabilities.completionProvider then
|
||||
vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
|
||||
end
|
||||
-- Enable inlay hints if supported
|
||||
if capabilities.inlayHintProvider then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end
|
||||
-- Some Lsp servers do not advertise inlay hints properly so enable this keybinding regardless
|
||||
vim.keymap.set('n', '<space>ht', function()
|
||||
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({bufnr = 0}), { bufnr = 0 })
|
||||
end,
|
||||
{ desc = '[H]ints [T]oggle', ${opts} }
|
||||
)
|
||||
-- Enable hover if supported
|
||||
if capabilities.hoverProvider then
|
||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, { desc = 'Hover Documentation', ${opts} })
|
||||
end
|
||||
-- Enable rename if supported
|
||||
if capabilities.renameProvider then
|
||||
vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, { desc = '[R]ename', ${opts} })
|
||||
end
|
||||
-- Enable code actions if supported
|
||||
if capabilities.codeActionProvider then
|
||||
vim.keymap.set({ 'n', 'v' }, '<leader>fa', vim.lsp.buf.code_action, { desc = '[F]ind Code [A]ctions', ${opts} })
|
||||
end
|
||||
-- Enable formatting if supported
|
||||
if capabilities.documentFormattingProvider then
|
||||
vim.keymap.set('n', '<leader>w', function() require("conform").format({ lsp_fallback = true }) end, { desc = 'Format Buffer', ${opts} })
|
||||
end
|
||||
-- Other keybinds
|
||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, { desc = '[G]o to [D]efinition', ${opts} })
|
||||
vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, { desc = '[G]o to [T]ype Definition', ${opts} })
|
||||
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, { desc = '[G]o to [I]mplementation', ${opts} })
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
17
modules/nixvim/default.nix
Normal file
17
modules/nixvim/default.nix
Normal file
|
@ -0,0 +1,17 @@
|
|||
{ lib, config, ... }:
|
||||
let
|
||||
cfg = config.jhome.nvim;
|
||||
in
|
||||
{
|
||||
imports = [ ./options.nix ];
|
||||
|
||||
config.programs.nixvim = lib.mkMerge [
|
||||
(import ./standalone.nix)
|
||||
(lib.mkIf cfg.enable {
|
||||
enable = true;
|
||||
nixpkgs.useGlobalPackages = true;
|
||||
defaultEditor = lib.mkDefault true;
|
||||
jhome.nvim = cfg;
|
||||
})
|
||||
];
|
||||
}
|
187
modules/nixvim/dev-plugins.nix
Normal file
187
modules/nixvim/dev-plugins.nix
Normal file
|
@ -0,0 +1,187 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) enableExceptInTests;
|
||||
cfg = config.jhome.nvim;
|
||||
enabledLSPs = [
|
||||
"basedpyright"
|
||||
"bashls"
|
||||
"clangd"
|
||||
# "html" # Not writing html
|
||||
"jsonls"
|
||||
"marksman"
|
||||
"ruff"
|
||||
"taplo"
|
||||
# "texlab" # Not using it
|
||||
"typos_lsp"
|
||||
# "typst_lsp" # Not using it
|
||||
"zls"
|
||||
];
|
||||
in
|
||||
{
|
||||
config = lib.mkIf cfg.dev.enable (
|
||||
lib.mkMerge [
|
||||
# Enable LSPs
|
||||
{
|
||||
plugins.lsp.servers = lib.genAttrs enabledLSPs (_: {
|
||||
enable = true;
|
||||
});
|
||||
}
|
||||
# Remove bundled LSPs
|
||||
(lib.mkIf (!cfg.dev.bundleLSPs) {
|
||||
plugins.lsp.servers = lib.genAttrs enabledLSPs (_: {
|
||||
package = null;
|
||||
});
|
||||
})
|
||||
# Configure LSPs
|
||||
{
|
||||
plugins = {
|
||||
lsp = {
|
||||
enable = true;
|
||||
servers = {
|
||||
# Pyright needs to have the project root set?
|
||||
basedpyright.rootDir = # lua
|
||||
''
|
||||
function()
|
||||
return vim.fs.root(0, {'flake.nix', '.git', '.jj', 'pyproject.toml', 'setup.py'})
|
||||
end
|
||||
'';
|
||||
bashls.package = lib.mkDefault pkgs.bash-language-server;
|
||||
# Adds ~2 GiB, install in a devShell instead
|
||||
clangd.package = lib.mkDefault null;
|
||||
# zls & other zig tools are big, install in a devShell instead
|
||||
zls.package = lib.mkDefault null;
|
||||
};
|
||||
};
|
||||
lspkind = {
|
||||
enable = true;
|
||||
mode = "symbol";
|
||||
extraOptions.maxwidth = 50;
|
||||
};
|
||||
lsp-lines.enable = true;
|
||||
};
|
||||
}
|
||||
# Configure Treesitter
|
||||
{
|
||||
plugins.treesitter = {
|
||||
enable = true;
|
||||
settings = {
|
||||
highlight.enable = true;
|
||||
indent.enable = true;
|
||||
incremental_election.enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
# Do not bundle treesitter grammars
|
||||
(lib.mkIf (!cfg.dev.bundleGrammars) { plugins.treesitter.grammarPackages = [ ]; })
|
||||
# Remove tools for building gramars when bundling them
|
||||
(lib.mkIf cfg.dev.bundleGrammars {
|
||||
plugins.treesitter = {
|
||||
gccPackage = null;
|
||||
nodejsPackage = null;
|
||||
treesitterPackage = null;
|
||||
};
|
||||
})
|
||||
# Configure Formatters
|
||||
{
|
||||
extraPackages = [
|
||||
pkgs.luajitPackages.jsregexp
|
||||
pkgs.shfmt
|
||||
pkgs.stylua
|
||||
pkgs.taplo
|
||||
pkgs.yamlfmt
|
||||
];
|
||||
plugins.conform-nvim = {
|
||||
enable = true;
|
||||
settings = {
|
||||
formatters.nixfmt.command = "${lib.getExe pkgs.nixfmt-rfc-style}";
|
||||
formatters_by_ft = {
|
||||
"_" = [ "trim_whitespace" ];
|
||||
c = [ "clang_format" ];
|
||||
cpp = [ "clang_format" ];
|
||||
lua = [ "stylua" ];
|
||||
nix = [ "nixfmt" ];
|
||||
rust = [ "rustfmt" ];
|
||||
sh = [ "shfmt" ];
|
||||
toml = [ "taplo" ];
|
||||
yaml = [ "yamlfmt" ];
|
||||
zig = [ "zigfmt" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
# Configure Linters
|
||||
{
|
||||
extraPackages = [
|
||||
pkgs.dash
|
||||
pkgs.statix
|
||||
];
|
||||
plugins.lint = {
|
||||
enable = true;
|
||||
lintersByFt = {
|
||||
# latex = [ "chktex" ]; # Not in use
|
||||
nix = [ "statix" ];
|
||||
sh = [ "dash" ];
|
||||
zsh = [ "zsh" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
# Jupyter notebooks
|
||||
{
|
||||
extraPackages = [ (pkgs.python3.withPackages (p: [ p.jupytext ])) ];
|
||||
plugins = {
|
||||
image.enable = enableExceptInTests;
|
||||
jupytext = {
|
||||
enable = true;
|
||||
settings.custom_language_formatting.python = {
|
||||
extension = "md";
|
||||
style = "markdown";
|
||||
force_ft = "markdown";
|
||||
};
|
||||
};
|
||||
molten = {
|
||||
enable = true;
|
||||
settings = {
|
||||
image_provider = "image.nvim";
|
||||
virt_text_output = true;
|
||||
molten_auto_open_output = false;
|
||||
molten_virt_lines_off_by_1 = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
# Rust plugins
|
||||
{
|
||||
plugins = {
|
||||
bacon = {
|
||||
enable = true;
|
||||
settings.quickfix.enabled = true;
|
||||
};
|
||||
rustaceanvim = {
|
||||
enable = true;
|
||||
# Install through rustup
|
||||
rustAnalyzerPackage = null;
|
||||
};
|
||||
};
|
||||
}
|
||||
# Other plugins
|
||||
{
|
||||
plugins = {
|
||||
colorizer = {
|
||||
enable = true;
|
||||
settings.user_default_options = {
|
||||
names = false; # disable named colors (i.e. red)
|
||||
mode = "virtualtext";
|
||||
};
|
||||
};
|
||||
otter.enable = true;
|
||||
};
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
11
modules/nixvim/extraPlugins/default.nix
Normal file
11
modules/nixvim/extraPlugins/default.nix
Normal file
|
@ -0,0 +1,11 @@
|
|||
{ pkgs }:
|
||||
let
|
||||
overlay = pkgs.callPackage ./generated.nix {
|
||||
inherit (pkgs.vimUtils) buildVimPlugin buildNeovimPlugin;
|
||||
};
|
||||
plugins = overlay pkgs pkgs;
|
||||
in
|
||||
{
|
||||
inherit overlay;
|
||||
inherit (plugins) nvim-silicon;
|
||||
}
|
23
modules/nixvim/extraPlugins/generated.nix
Normal file
23
modules/nixvim/extraPlugins/generated.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
# GENERATED by ./pkgs/applications/editors/vim/plugins/update.py. Do not edit!
|
||||
{
|
||||
lib,
|
||||
buildVimPlugin,
|
||||
buildNeovimPlugin,
|
||||
fetchFromGitHub,
|
||||
fetchgit,
|
||||
}:
|
||||
|
||||
final: prev: {
|
||||
nvim-silicon = buildVimPlugin {
|
||||
pname = "nvim-silicon";
|
||||
version = "2024-08-31";
|
||||
src = fetchFromGitHub {
|
||||
owner = "michaelrommel";
|
||||
repo = "nvim-silicon";
|
||||
rev = "9fe6001dc8cad4d9c53bcfc8649e3dc76ffa169c";
|
||||
sha256 = "1qczi06yndkr2pmwidlkgmk0395x189sznvscn4fnr96jx58j5yl";
|
||||
};
|
||||
meta.homepage = "https://github.com/michaelrommel/nvim-silicon/";
|
||||
};
|
||||
|
||||
}
|
2
modules/nixvim/extraPlugins/plugins
Normal file
2
modules/nixvim/extraPlugins/plugins
Normal file
|
@ -0,0 +1,2 @@
|
|||
repo,branch,alias
|
||||
https://github.com/michaelrommel/nvim-silicon/,,
|
229
modules/nixvim/mappings.nix
Normal file
229
modules/nixvim/mappings.nix
Normal file
|
@ -0,0 +1,229 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
helpers,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
cfg = config.jhome.nvim;
|
||||
in
|
||||
{
|
||||
config.keymaps =
|
||||
[
|
||||
# Quickfix
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qo";
|
||||
action = "<cmd>Copen<CR>";
|
||||
options.desc = "Quickfix Open";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qq";
|
||||
action = "<cmd>cclose<CR>";
|
||||
options.desc = "Quickfix Quit";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qj";
|
||||
action = "<cmd>cnext<CR>";
|
||||
options.desc = "Quickfix next [J]";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>qk";
|
||||
action = "<cmd>cprev<CR>";
|
||||
options.desc = "Quickfix previous [K]";
|
||||
}
|
||||
# Open or create file
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>gf";
|
||||
action = "<cmd>e <cfile><CR>";
|
||||
options.desc = "Go to File";
|
||||
}
|
||||
# Keep Selection when indenting
|
||||
{
|
||||
mode = "x";
|
||||
key = ">";
|
||||
action = ">gv";
|
||||
options.desc = "Indent Selection";
|
||||
}
|
||||
{
|
||||
mode = "x";
|
||||
key = "<";
|
||||
action = "<gv";
|
||||
options.desc = "Deindent Selection";
|
||||
}
|
||||
# Diagnostics
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>dj";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
vim.diagnostic.goto_next
|
||||
'';
|
||||
options.desc = "Diagnostics next [J]";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>dk";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
vim.diagnostic.goto_prev
|
||||
'';
|
||||
options.desc = "Diagnostics previous [K]";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xs";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('symbols') end
|
||||
'';
|
||||
options.desc = "Toggle Diagnostics trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xd";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('diagnostics') end
|
||||
'';
|
||||
options.desc = "Toggle Diagnostics trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xq";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('quickfix') end
|
||||
'';
|
||||
options.desc = "Toggle Quickfix trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>xl";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('loclist') end
|
||||
'';
|
||||
options.desc = "Toggle Loclist trouble";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "gR";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
function() require('trouble').toggle_preview('lsp_references') end
|
||||
'';
|
||||
options.desc = "Toggle lsp References trouble";
|
||||
}
|
||||
# Telescope
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>ff";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').find_files
|
||||
'';
|
||||
options.desc = "Find Files";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fg";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').live_grep
|
||||
'';
|
||||
options.desc = "Find Grep";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fh";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').help_tags
|
||||
'';
|
||||
options.desc = "Find Help";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fb";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').buffers
|
||||
'';
|
||||
options.desc = "Find Buffer";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fd";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').diagnostics
|
||||
'';
|
||||
options.desc = "Find Diagnostics";
|
||||
}
|
||||
{
|
||||
mode = "n";
|
||||
key = "<leader>fq";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('telescope.builtin').quickfix
|
||||
'';
|
||||
options.desc = "Find Quickfix";
|
||||
}
|
||||
]
|
||||
# Nvim Silicon
|
||||
++ lib.optional (!cfg.reduceSize) {
|
||||
mode = "v";
|
||||
key = "<leader>sc";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('nvim-silicon').clip
|
||||
|
||||
'';
|
||||
options.desc = "Snap Code (to clipboard)";
|
||||
}
|
||||
++ lib.optional cfg.dev.enable {
|
||||
mode = "n";
|
||||
key = "<leader>w";
|
||||
action =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
require('conform').format
|
||||
'';
|
||||
options.desc = "Format buffer";
|
||||
};
|
||||
}
|
37
modules/nixvim/options.nix
Normal file
37
modules/nixvim/options.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkEnableOption mkOption types;
|
||||
mkDisableOption =
|
||||
desc:
|
||||
mkEnableOption desc
|
||||
// {
|
||||
default = true;
|
||||
example = false;
|
||||
};
|
||||
in
|
||||
{
|
||||
options.jhome.nvim = {
|
||||
enable = mkDisableOption "jalil's Neovim configuration";
|
||||
reduceSize = mkEnableOption "reduce size by disabling big modules";
|
||||
dev = mkOption {
|
||||
type = types.submodule {
|
||||
options = {
|
||||
enable = mkDisableOption "development configuration";
|
||||
bundleLSPs = mkDisableOption "bundling LSPs with Neovim (decreases size when disabled)";
|
||||
bundleGrammars = mkDisableOption "bundling treesitter grammars with Neovim (barely decreases size when disabled)";
|
||||
};
|
||||
};
|
||||
default = { };
|
||||
example = {
|
||||
enable = false;
|
||||
};
|
||||
description = ''
|
||||
Development options
|
||||
|
||||
Disabling this is advised for headless setups (e.g. servers), where you
|
||||
won't be doing software development and would prefer to instead have a
|
||||
smaller package.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
178
modules/nixvim/plugins.nix
Normal file
178
modules/nixvim/plugins.nix
Normal file
|
@ -0,0 +1,178 @@
|
|||
{ lib, helpers, ... }:
|
||||
let
|
||||
inherit (helpers) mkRaw;
|
||||
in
|
||||
{
|
||||
config.plugins = {
|
||||
cmp = {
|
||||
enable = true;
|
||||
cmdline = {
|
||||
"/" = {
|
||||
mapping =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
cmp.mapping.preset.cmdline()
|
||||
'';
|
||||
sources = [
|
||||
{ name = "rg"; }
|
||||
{ name = "buffer"; }
|
||||
];
|
||||
};
|
||||
":" = {
|
||||
mapping =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
cmp.mapping.preset.cmdline()
|
||||
'';
|
||||
sources = [
|
||||
{ name = "path"; }
|
||||
{ name = "cmdline"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
settings = {
|
||||
# Snippets
|
||||
snippet.expand =
|
||||
# lua
|
||||
''
|
||||
function(args) require('luasnip').lsp_expand(args.body) end
|
||||
'';
|
||||
# Completion Sources
|
||||
sources = [
|
||||
{
|
||||
name = "buffer";
|
||||
groupIndex = 3;
|
||||
}
|
||||
{
|
||||
name = "calc";
|
||||
groupIndex = 2;
|
||||
}
|
||||
{
|
||||
name = "conventionalcommits";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "crates";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "luasnip";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "nvim_lsp";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "nvim_lsp_document_symbol";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "nvim_lsp_signature_help";
|
||||
groupIndex = 1;
|
||||
}
|
||||
{
|
||||
name = "path";
|
||||
groupIndex = 2;
|
||||
}
|
||||
{
|
||||
name = "spell";
|
||||
groupIndex = 2;
|
||||
}
|
||||
{
|
||||
name = "treesitter";
|
||||
groupIndex = 2;
|
||||
}
|
||||
];
|
||||
mapping =
|
||||
mkRaw
|
||||
# lua
|
||||
''
|
||||
cmp.mapping.preset.insert({
|
||||
["<C-n>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif require("luasnip").expand_or_jumpable() then
|
||||
require("luasnip").expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<C-p>"] = function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif require("luasnip").jumpable(-1) then
|
||||
require("luasnip").jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end,
|
||||
["<C-u>"] = cmp.mapping(function(fallback)
|
||||
if require("luasnip").choice_active() then
|
||||
require("luasnip").next_choice()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-Space>"] = cmp.mapping.complete { },
|
||||
["<C-e>"] = cmp.mapping.close(),
|
||||
["<CR>"] = cmp.mapping.confirm { select = true },
|
||||
})
|
||||
'';
|
||||
};
|
||||
};
|
||||
gitsigns.enable = true;
|
||||
lualine = {
|
||||
enable = true;
|
||||
settings.options.theme = lib.mkForce "gruvbox";
|
||||
};
|
||||
luasnip = {
|
||||
enable = true;
|
||||
settings.update_events = "TextChanged,TextChangedI";
|
||||
};
|
||||
noice = {
|
||||
enable = true;
|
||||
settings = {
|
||||
lsp.override = {
|
||||
"vim.lsp.util.convert_input_to_markdown_lines" = true;
|
||||
"vim.lsp.util.stylize_markdown" = true;
|
||||
"cmp.entry.get_documentation" = true;
|
||||
};
|
||||
presets = {
|
||||
# use a classic bottom cmdline for search
|
||||
bottom_search = true;
|
||||
# position the cmdline and popupmenu together
|
||||
command_palette = false;
|
||||
# long messages will be sent to a split
|
||||
long_message_to_split = true;
|
||||
# enables an input dialog for inc-rename.nvim
|
||||
inc_rename = false;
|
||||
# add a border to hover docs and signature help
|
||||
lsp_doc_border = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
notify = {
|
||||
enable = true;
|
||||
settings.background_colour = "#000000";
|
||||
};
|
||||
telescope = {
|
||||
enable = true;
|
||||
extensions = {
|
||||
ui-select.enable = true;
|
||||
fzy-native.enable = true;
|
||||
};
|
||||
};
|
||||
trouble = {
|
||||
enable = true;
|
||||
settings.auto_close = true;
|
||||
};
|
||||
web-devicons.enable = true;
|
||||
};
|
||||
}
|
104
modules/nixvim/standalone.nix
Normal file
104
modules/nixvim/standalone.nix
Normal file
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
lib,
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jhome.nvim;
|
||||
plugins = pkgs.vimPlugins;
|
||||
extraPlugins = import ./extraPlugins { inherit pkgs; };
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
./options.nix
|
||||
./plugins.nix
|
||||
./dev-plugins.nix
|
||||
./mappings.nix
|
||||
./augroups.nix
|
||||
];
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
withRuby = false;
|
||||
globals.mapleader = " ";
|
||||
# Appearance
|
||||
colorschemes.gruvbox = {
|
||||
enable = true;
|
||||
settings = {
|
||||
bold = true;
|
||||
transparent_mode = true;
|
||||
terminal_colors = true;
|
||||
};
|
||||
};
|
||||
opts = {
|
||||
number = true;
|
||||
relativenumber = true;
|
||||
colorcolumn = "+1";
|
||||
cursorline = true;
|
||||
wrap = false;
|
||||
splitright = true;
|
||||
# Tabs & indentation
|
||||
smarttab = true;
|
||||
autoindent = true;
|
||||
smartindent = true;
|
||||
# Search path
|
||||
path = ".,/usr/include,**";
|
||||
wildmenu = true;
|
||||
hlsearch = true;
|
||||
incsearch = true;
|
||||
ignorecase = true; # Search ignores cases
|
||||
smartcase = true; # Unless it has a capital letter
|
||||
# Enable local configuration :h 'exrc'
|
||||
exrc = true; # safe since nvim 0.9
|
||||
};
|
||||
extraPlugins = [
|
||||
plugins.nui-nvim
|
||||
plugins.nvim-web-devicons
|
||||
plugins.vim-jjdescription # FIXME: included since neovim nightly
|
||||
];
|
||||
extraPackages = [ pkgs.luajitPackages.jsregexp ];
|
||||
extraConfigLuaPre =
|
||||
# lua
|
||||
''
|
||||
-- Lua Pre Config
|
||||
if vim.fn.has 'termguicolors' then
|
||||
-- Enable RGB colors
|
||||
vim.g.termguicolors = true
|
||||
end
|
||||
|
||||
-- Useful function
|
||||
local has_words_before = function()
|
||||
-- unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0
|
||||
and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil
|
||||
end
|
||||
-- END: Lua Pre Config
|
||||
'';
|
||||
}
|
||||
# Big packages that are kinda unnecessary
|
||||
(lib.mkIf (!cfg.reduceSize) {
|
||||
extraPlugins = [ extraPlugins.nvim-silicon ];
|
||||
extraPackages = [ pkgs.silicon ];
|
||||
extraConfigLua =
|
||||
# lua
|
||||
''
|
||||
-- Lua Config
|
||||
require("nvim-silicon").setup {
|
||||
theme = "gruvbox-dark",
|
||||
pad_horiz = 16,
|
||||
pad_vert = 16,
|
||||
-- Current buffer name
|
||||
window_title = function()
|
||||
return vim.fn.fnamemodify(
|
||||
vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()),
|
||||
":t"
|
||||
)
|
||||
end,
|
||||
}
|
||||
-- END: Lua Config
|
||||
'';
|
||||
})
|
||||
];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue