working nvf!

This commit is contained in:
Charlie Root 2024-07-06 17:14:45 +02:00
commit 2a80c2bac1
53 changed files with 330 additions and 172 deletions

View file

@ -81,7 +81,7 @@
helix.enable = true;
kakoune.enable = true;
nixvim.enable = false; # broken at the moment
# neovim.enable = true;
neovim.enable = true;
};
services = {
pipewire.enable = true;

View file

@ -1,6 +1,7 @@
{
inputs,
config,
lib,
inputs,
...
}: let
inherit (builtins) filter map toString elem;
@ -10,7 +11,7 @@
mkNeovimModule = {
path,
ingoredPaths ? [./nvf.nix],
ingoredPaths ? [./nvf.nix ./plugins/sources/default.nix],
}:
filter (hasSuffix ".nix") (
map toString (
@ -22,7 +23,7 @@
in {
imports = concatLists [
# neovim-flake home-manager module
[nvf.homeManagerModules.default]
[nvf.nixosModules.default]
# construct this entore directory as a module
# which means all default.nix files will be imported automtically

View file

@ -1,14 +1,88 @@
{
config,
self,
pkgs,
...
}: let
inherit (config.modules.other.system) username;
inherit (pkgs.vimPlugins) friendly-snippets aerial-nvim nvim-surround undotree mkdir-nvim ssr-nvim direnv-vim legendary-nvim;
pluginSources = import ./sources {inherit self pkgs;};
inherit (pkgs) fetchFromGitHub;
inherit (pkgs.vimUtils) buildVimPlugin;
pluginSources = {
smart-splits = buildVimPlugin {
name = "smart-splits";
src = fetchFromGitHub {
owner = "mrjones2014";
repo = "smart-splits.nvim";
rev = "95833675cd92538bf9cded1d2d58d1fc271c5428";
hash = "sha256-TsEzHalLTLp9USV0aGRadAObViC/OpIJeuEJ95lJUL8=";
};
};
regexplainer = buildVimPlugin {
name = "nvim-regexplainer";
src = fetchFromGitHub {
owner = "bennypowers";
repo = "nvim-regexplainer";
rev = "4250c8f3c1307876384e70eeedde5149249e154f";
hash = "sha256-15DLbKtOgUPq4DcF71jFYu31faDn52k3P1x47GL3+b0=";
};
};
specs-nvim = buildVimPlugin {
name = "specs.nvim";
src = fetchFromGitHub {
owner = "notashelf";
repo = "specs.nvim";
rev = "0792aaebf8cbac0c8545c43ad648b98deb83af42";
hash = "sha256-doHE/3bRuC8lyYxMk927JmwLfiy7aR22+i+BNefEGJ4=";
};
};
deferred-clipboard = buildVimPlugin {
name = "deferred-clipboard";
src = fetchFromGitHub {
owner = "EtiamNullam";
repo = "deferred-clipboard.nvim";
rev = "810a29d166eaa41afc220cc7cd85eeaa3c43b37f";
hash = "sha256-nanNQEtpjv0YKEkkrPmq/5FPxq+Yj/19cs0Gf7YgKjU=";
};
};
/*
data-viewer-nvim = buildVimPlugin {
name = "data-viewer.nvim";
src = fetchFromGitHub {
owner = "VidocqH";
repo = "data-viewer.nvim";
rev = "40ddf37bb7ab6c04ff9e820812d1539afe691668";
hash = "sha256-D5hvLhsYski11H9qiDDL2zlZMtYmbpHgpewiWR6C7rE=";
};
};
*/
vim-nftables = buildVimPlugin {
name = "vim-nftables";
src = fetchFromGitHub {
owner = "awisse";
repo = "vim-nftables";
rev = "bc29309080b4c7e1888ffb1a830846be16e5b8e7";
hash = "sha256-L1x3Hv95t/DBBrLtPBKrqaTbIPor/NhVuEHVIYo/OaA=";
};
};
neotab-nvim = buildVimPlugin {
name = "neotab.nvim";
src = fetchFromGitHub {
owner = "kawre";
repo = "neotab.nvim";
rev = "6c6107dddaa051504e433608f59eca606138269b";
hash = "sha256-bSFKbjj8fJHdfBzYoQ9l3NU0GAYfdfCbESKbwdbLNSw=";
};
};
};
in {
home-manager.users.${username}.programs.neovim-flake.settings.vim.extraPlugins = {
programs.neovim-flake.settings.vim.extraPlugins = {
# plugins that are pulled from nixpkgs
direnv = {package = direnv-vim;};
friendly-snippets = {package = friendly-snippets;};
@ -46,7 +120,7 @@ in {
# plugins that are built from their sources
regexplainer = {package = pluginSources.regexplainer;};
vim-nftables = {package = pluginSources.vim-nftables;};
/*
data-view = {
package = pluginSources.data-viewer-nvim;
setup = ''
@ -63,16 +137,7 @@ in {
vim.api.nvim_set_keymap('n', '<leader>dvc', ':DataViewerClose<CR>', {noremap = true})
'';
};
slides-nvim = {
package = pluginSources.slides-nvim;
setup = "require('slides').setup {}";
};
hmts = {
package = pluginSources.hmts;
after = ["treesitter"];
};
*/
smart-splits = {
package = pluginSources.smart-splits;

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
assistant.copilot = {
enable = true;
cmp.enable = true;

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
autocomplete = {
enable = true;
type = "nvim-cmp";

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
autopairs.enable = true;
};
}

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
binds = {
whichKey.enable = true;
cheatsheet.enable = false;

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
comments.comment-nvim.enable = true;
};
}

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
dashboard = {
alpha.enable = true;
};

View file

@ -1,7 +1,7 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
debugger.nvim-dap = {
enable = true;
ui.enable = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
filetree = {
nvimTree = {

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
gestures.gesture-nvim.enable = false;
};

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
git = {
enable = true;

View file

@ -6,7 +6,7 @@
}: let
inherit (config.modules.other.system) username;
in {
home-manager.users.${username}.programs.neovim-flake.settings.vim = {
programs.neovim-flake.settings.vim = {
languages = {
enableLSP = true;
enableFormat = true;
@ -28,17 +28,6 @@ in {
elixir.enable = false;
svelte.enable = false;
sql.enable = false;
java = let
jdtlsCache = "${config.xdg.cacheHome}/jdtls";
in {
enable = true;
lsp.package = [
"${lib.getExe pkgs.jdt-language-server}"
"-configuration ${jdtlsCache}/config"
"-data ${jdtlsCache}/workspace"
];
};
lua = {
enable = true;
lsp.neodev.enable = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
lsp = {
formatOnSave = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
minimap = {
# cool for vanity but practically useless on small screens

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
notes = {
todo-comments.enable = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
notify = {
nvim-notify.enable = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
presence.neocord.enable = false;
};

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
projects = {
project-nvim = {

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
session.nvim-session-manager = {
enable = false;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
statusline = {
lualine = {

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
tabline = {
nvimBufferline.enable = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
telescope.enable = true;
};

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
};
}

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
terminal = {
toggleterm = {

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
theme = {
enable = true;

View file

@ -5,7 +5,6 @@
}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
treesitter = {
fold = true;

View file

@ -5,7 +5,6 @@
}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
ui = {
noice.enable = true;

View file

@ -5,7 +5,6 @@
}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
utility = {
ccc.enable = true;

View file

@ -1,7 +1,6 @@
{config, ...}: let
inherit (config.modules.other.system) username;
in {
home-manager.${username}.
programs.neovim-flake.settings.vim = {
visuals = {
enable = true;

View file

@ -1,85 +0,0 @@
{
self,
pkgs,
...
}: let
inherit (self) pins;
inherit (pkgs) fetchFromGitHub;
inherit (pkgs.vimUtils) buildVimPlugin;
sources = {
hmts = buildVimPlugin {
name = "hmts.nvim";
src = pins."hmts.nvim";
};
smart-splits = buildVimPlugin {
name = "smart-splits";
src = fetchFromGitHub {
owner = "mrjones2014";
repo = "smart-splits.nvim";
rev = "95833675cd92538bf9cded1d2d58d1fc271c5428";
hash = "";
};
regexplainer = buildVimPlugin {
name = "nvim-regexplainer";
src = fetchFromGitHub {
owner = "bennypowers";
repo = "nvim-regexplainer";
rev = "4250c8f3c1307876384e70eeedde5149249e154f";
hash = "sha256-15DLbKtOgUPq4DcF71jFYu31faDn52k3P1x47GL3+b0=";
};
};
specs-nvim = buildVimPlugin {
name = "specs.nvim";
src = fetchFromGitHub {
owner = "notashelf";
repo = "specs.nvim";
rev = "0792aaebf8cbac0c8545c43ad648b98deb83af42";
hash = "sha256-doHE/3bRuC8lyYxMk927JmwLfiy7aR22+i+BNefEGJ4=";
};
};
deferred-clipboard = buildVimPlugin {
name = "deferred-clipboard";
src = fetchFromGitHub {
owner = "EtiamNullam";
repo = "deferred-clipboard.nvim";
rev = "810a29d166eaa41afc220cc7cd85eeaa3c43b37f";
hash = "sha256-nanNQEtpjv0YKEkkrPmq/5FPxq+Yj/19cs0Gf7YgKjU=";
};
};
data-viewer-nvim = buildVimPlugin {
name = "data-viewer.nvim";
src = fetchFromGitHub {
owner = "VidocqH";
repo = "data-viewer.nvim";
rev = "40ddf37bb7ab6c04ff9e820812d1539afe691668";
hash = "sha256-D5hvLhsYski11H9qiDDL2zlZMtYmbpHgpewiWR6C7rE=";
};
};
vim-nftables = buildVimPlugin {
name = "vim-nftables";
src = fetchFromGitHub {
owner = "awisse";
repo = "vim-nftables";
rev = "bc29309080b4c7e1888ffb1a830846be16e5b8e7";
hash = "sha256-L1x3Hv95t/DBBrLtPBKrqaTbIPor/NhVuEHVIYo/OaA=";
};
};
neotab-nvim = buildVimPlugin {
name = "neotab.nvim";
src = fetchFromGitHub {
owner = "kawre";
repo = "neotab.nvim";
rev = "6c6107dddaa051504e433608f59eca606138269b";
hash = "sha256-bSFKbjj8fJHdfBzYoQ9l3NU0GAYfdfCbESKbwdbLNSw=";
};
};
};
};
in
sources

View file

@ -0,0 +1,8 @@
-- luacheck: ignore
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = 'gitconfig*,.gitconfig*',
callback = function()
vim.bo.filetype = 'gitconfig'
end,
once = false,
})

View file

@ -0,0 +1,8 @@
-- luacheck: ignore
vim.api.nvim_create_autocmd({ 'BufNewFile', 'BufRead' }, {
pattern = '*.graphql,*.graphqls,*.gql',
callback = function()
vim.bo.filetype = 'graphql'
end,
once = false,
})

View file

@ -0,0 +1,4 @@
-- luacheck: ignore
vim.filetype.add({
filename = { ['.envrc'] = 'bash' },
})

View file

@ -0,0 +1,2 @@
-- luacheck: ignore
vim.opt_local.textwidth = 80

View file

@ -0,0 +1,5 @@
-- luacheck: ignore
vim.opt_local.tabstop = 4
vim.opt_local.shiftwidth = 0
vim.opt_local.expandtab = false
vim.opt_local.list = false

View file

@ -0,0 +1,14 @@
vim.keymap.set('n', '<leader>jf', '<cmd>%!jq<cr>', { noremap = true, silent = true, desc = 'Format with jq' })
vim.keymap.set('n', '<leader>jm', '<cmd>%!jq -c<cr>', { noremap = true, silent = true, desc = 'Minify with jq' })
-- add comma to the end of the line on new line
vim.keymap.set('n', 'o', function()
local line = vim.api.nvim_get_current_line()
local should_add_comma = string.find(line, '[^,{[]$')
if should_add_comma then
return 'A,<cr>'
else
return 'o'
end
end, { buffer = true, expr = true })

View file

@ -0,0 +1,13 @@
-- luacheck: ignore
local opts = { noremap = true, silent = true, buffer = 0 }
local wincmd = vim.b.pager and 'q' or 'c'
vim.keymap.set('n', 'q', '<cmd>lclose<CR><C-W>' .. wincmd, opts)
vim.keymap.set('n', '<Leader>o', function()
-- TODO: can this be done in a floating window?
require('man').show_toc()
end, opts)
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
.. (vim.b.undo_ftplugin ~= nil and ' | ' or '')
.. 'sil! nunmap <buffer> <Leader>o'
.. ' | sil! nunmap <buffer> q'

View file

@ -0,0 +1,30 @@
-- luacheck: ignore
vim.opt_local.textwidth = 80
local CR = vim.api.nvim_replace_termcodes('<cr>', true, true, true)
local function toggle_checkbox()
local cursor = vim.api.nvim_win_get_cursor(0)
local lineno = cursor[1]
local line = vim.api.nvim_buf_get_lines(0, lineno - 1, lineno, false)[1] or ''
if string.find(line, '%[ %]') then
line = line:gsub('%[ %]', '%[x%]')
else
line = line:gsub('%[x%]', '%[ %]')
end
vim.api.nvim_buf_set_lines(0, lineno - 1, lineno, false, { line })
vim.api.nvim_win_set_cursor(0, cursor)
pcall(vim.fn['repeat#set'], ':ToggleCheckbox' .. CR)
end
vim.api.nvim_create_user_command(
'ToggleCheckbox',
toggle_checkbox,
vim.tbl_extend('force', { desc = 'toggle checkboxes' }, {})
)
vim.keymap.set('n', '<leader>op', toggle_checkbox, {
noremap = true,
silent = true,
desc = 'Toggle checkbox',
buffer = 0,
})

View file

@ -0,0 +1,2 @@
-- luacheck: ignore
vim.wo.wrap = true

View file

@ -0,0 +1,2 @@
-- luacheck: ignore
vim.opt_local.shiftwidth = 2

View file

@ -0,0 +1,30 @@
; extends
; inject sql into any const string with word query in the name
; e.g. const query = `SELECT * FROM users WHERE name = 'John'`;
(const_spec
name: (identifier) @_name (#match? @_name "[Qq]uery")
value: (expression_list
(raw_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql"))
; inject sql in single line strings
(call_expression
(selector_expression
field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind"))
(argument_list
(raw_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql")
)
; inject sql in multi line strings
(call_expression
(selector_expression
field: (field_identifier) @_field (#any-of? @_field "GetContext" "Get" "ExecContext" "Exec" "SelectContext" "Select" "In" "Rebind"))
(argument_list
(interpreted_string_literal) @injection.content)
(#offset! @injection.content 0 1 0 -1)
(#set! injection.language "sql")
)

View file

@ -0,0 +1,2 @@
;; extends
(( jsx_text ) @injection.content (#set! injection.language "markdown") )

View file

@ -0,0 +1,5 @@
;extends
(fenced_code_block (code_fence_content) @class.inner) @class.outer
(paragraph) @function.outer @function.inner

View file

@ -0,0 +1,12 @@
;extends
[
(shortcut_link)
] @nospell
(strikethrough
(emphasis_delimiter)
(strikethrough
(emphasis_delimiter)
(emphasis_delimiter))
(emphasis_delimiter))@markup.doublestrikethrough

View file

@ -0,0 +1,9 @@
((jsx_section)
@injection.content
(#set! injection.language "tsx")
(#set! injection.include-children))
((markdown_section)
@injection.content
(#set! injection.language "markdown")
(#set! injection.combined))

View file

@ -0,0 +1,14 @@
;extends
(macro_invocation
(scoped_identifier
path: (identifier) @path (#eq? @path "sqlx")
name: (identifier) @name (#match? @name "^query.*")
)
(token_tree
(raw_string_literal) @injection.content
(#set! injection.language "sql")
(#set! injection.include-children)
)
(#offset! @injection.content 0 3 0 -2)
)

View file

@ -0,0 +1,5 @@
;; extends
((ident) @constant
(#eq? @constant "lambda")
(#set! conceal "λ")
)

View file

@ -0,0 +1,42 @@
contrib
Contrib
gitignore
dotfiles
nyx
notashelf
utils
neovim
glab
gh
ripgrep
wip
thoughtbot
kubectl
CoC
config
Capybara
mailserver
Mailserver
anyrun
ags
spicetify
Spicetify
firefox
Firefox
Hyprland
Hyprwm
Xorg
X11
devShell
devshell
nixos
NixOS
nixpkgs
Nixpkgs
filetree
sourcetree
url
uri

Binary file not shown.

View file

@ -1,19 +1,19 @@
# Credity to raf aka Notashelf, link to his repo is in the README.md
# Credits to raf aka Notashelf, link to his repo is in the README.md
{
inputs,
config,
pkgs,
lib,
pkgs,
inputs,
...
}: let
inherit (builtins) filter map toString path isPath throw;
inherit (lib.filesystem) listFilesRecursive;
inherit (lib.strings) hasSuffix fileContents;
inherit (lib.attrsets) genAttrs;
inherit (config.modues.other.system) username;
inherit (lib) mkIf mkEnableOption;
cfg = config.modules.editors.neovim;
nvf = inputs.neovim-flake;
inherit (inputs) neovim-nightly-overlay;
inherit (nvf.lib.nvim.dag) entryBefore entryAnywhere;
mkRuntimeDir = name: let
@ -24,7 +24,8 @@
path = toString finalPath;
};
in {
home-manager.users.${username} = {
options.modules.editors.neovim.enable = mkEnableOption "neovim";
config = mkIf cfg.enable {
programs.neovim-flake = {
enable = true;
@ -36,8 +37,7 @@ in {
# use neovim-unwrapped from nixpkgs
# alternatively, neovim-nightly from the neovim-nightly overlay
# via inputs.neovim-nightly.packages.${pkgs.stdenv.system}.neovim
# package = pkgs.neovim-unwrapped;
package = neovim-nightly-overlay;
package = pkgs.neovim-unwrapped;
viAlias = true;
vimAlias = true;
@ -50,7 +50,8 @@ in {
useSystemClipboard = true;
spellcheck = {
enable = true;
languages = ["en" "de"];
# TODO add de
languages = ["en"];
};
enableLuaLoader = true;
@ -81,7 +82,7 @@ in {
# directory, so we do not need to use require
luaConfigRC = let
# get the name of each lua file in the lua directory, where setting files reside
# and import tham recursively
# and import them recursively
configPaths = filter (hasSuffix ".lua") (map toString (listFilesRecursive ./lua));
# generates a key-value pair that looks roughly as follows: