Convert nvim to nixvim, everything works except format and highlight on mouseover

This commit is contained in:
Artemis Tosini 2023-09-07 05:01:23 +00:00
parent 48859df9de
commit 2dd865c192
Signed by: artemist
GPG key ID: ADFFE553DCBB831E
8 changed files with 367 additions and 171 deletions

View file

@ -1,5 +1,28 @@
{
"nodes": {
"beautysh": {
"inputs": {
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"poetry2nix": "poetry2nix",
"utils": "utils"
},
"locked": {
"lastModified": 1680308980,
"narHash": "sha256-aUEHV0jk2qIFP3jlsWYWhBbm+w/N9gzH3e4I5DcdB5s=",
"owner": "lovesegfault",
"repo": "beautysh",
"rev": "9845efc3ea3e86cc0d41465d720a47f521b2799c",
"type": "github"
},
"original": {
"owner": "lovesegfault",
"repo": "beautysh",
"type": "github"
}
},
"crane": {
"inputs": {
"flake-compat": [
@ -49,6 +72,22 @@
"type": "github"
}
},
"flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1673956053,
"narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
@ -88,6 +127,42 @@
"type": "github"
}
},
"flake-utils_2": {
"inputs": {
"systems": "systems_2"
},
"locked": {
"lastModified": 1692799911,
"narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1685518550,
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
@ -110,6 +185,28 @@
"type": "github"
}
},
"gitignore_2": {
"inputs": {
"nixpkgs": [
"nixvim",
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1660459072,
"narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "a20de23b925fd8264fd7fad6454652e142fd7f73",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"home-manager": {
"inputs": {
"nixpkgs": [
@ -204,6 +301,97 @@
"type": "github"
}
},
"nixpkgs-stable_2": {
"locked": {
"lastModified": 1685801374,
"narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c37ca420157f4abc31e26f436c1145f8951ff373",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixvim": {
"inputs": {
"beautysh": "beautysh",
"flake-utils": "flake-utils_2",
"nixpkgs": [
"nixpkgs"
],
"pre-commit-hooks": "pre-commit-hooks"
},
"locked": {
"lastModified": 1693862861,
"narHash": "sha256-+ynDsujluFf187KZvyBZ1C/BTty3TtKWuzuvpQ7sy/Q=",
"owner": "nix-community",
"repo": "nixvim",
"rev": "b7611f74a9b1107e09925664f652b141926b0b92",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixvim",
"type": "github"
}
},
"poetry2nix": {
"inputs": {
"flake-utils": [
"nixvim",
"beautysh",
"utils"
],
"nixpkgs": [
"nixvim",
"beautysh",
"nixpkgs"
]
},
"locked": {
"lastModified": 1658665240,
"narHash": "sha256-/wkx7D7enyBPRjIkK0w7QxLQhzEkb3UxNQnjyc3FTUI=",
"owner": "nix-community",
"repo": "poetry2nix",
"rev": "8b8edc85d24661d5a6d0d71d6a7011f3e699780f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "poetry2nix",
"type": "github"
}
},
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"gitignore": "gitignore_2",
"nixpkgs": [
"nixvim",
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable_2"
},
"locked": {
"lastModified": 1692274144,
"narHash": "sha256-BxTQuRUANQ81u8DJznQyPmRsg63t4Yc+0kcyq6OLz8s=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"pre-commit-hooks-nix": {
"inputs": {
"flake-compat": [
@ -257,9 +445,10 @@
"lanzaboote": "lanzaboote",
"nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim",
"private": "private",
"rustybar": "rustybar",
"utils": "utils_2",
"utils": "utils_3",
"wip-pinebook-pro": "wip-pinebook-pro"
}
},
@ -293,7 +482,7 @@
"nixpkgs": [
"nixpkgs"
],
"utils": "utils"
"utils": "utils_2"
},
"locked": {
"lastModified": 1637380210,
@ -339,7 +528,52 @@
"type": "github"
}
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_4": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1678901627,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"utils_2": {
"locked": {
"lastModified": 1637014545,
"narHash": "sha256-26IZAc5yzlD9FlDT54io1oqG/bBoyka+FJk5guaX4x4=",
@ -354,9 +588,9 @@
"type": "github"
}
},
"utils_2": {
"utils_3": {
"inputs": {
"systems": "systems_2"
"systems": "systems_4"
},
"locked": {
"lastModified": 1692799911,

View file

@ -14,6 +14,11 @@
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
rustybar = {
url = "github:mildlyfunctionalgays/rustybar";
inputs.nixpkgs.follows = "nixpkgs";
@ -28,7 +33,7 @@
};
};
outputs = { self, nixpkgs, home-manager, private, utils, ... }@inputs:
outputs = { self, nixpkgs, home-manager, private, utils, nixvim, ... }@inputs:
let
makeSystem = conf:
nixpkgs.lib.nixosSystem (nixpkgs.lib.recursiveUpdate conf rec {
@ -36,6 +41,7 @@
modules = [
private.nixosModules.base
home-manager.nixosModules.home-manager
nixvim.nixosModules.nixvim
{ home-manager.extraSpecialArgs = specialArgs; }
] ++ (conf.modules or [ ]);
});

View file

@ -6,8 +6,7 @@
useGlobalPkgs = true;
};
home-manager.users.artemis = {
imports =
[ ./fish.nix ./gtk.nix ./git.nix ./mpv.nix ./kitty.nix ./neovim ./ssh ];
imports = [ ./fish.nix ./gtk.nix ./git.nix ./mpv.nix ./kitty.nix ./ssh ];
home.stateVersion = config.system.stateVersion;

View file

@ -1,60 +0,0 @@
{ config, pkgs, ... }:
let
lsp-colors = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "lsp-colors.nvim";
version = "2021-10-22";
src = pkgs.fetchFromGitHub {
owner = "folke";
repo = "lsp-colors.nvim";
rev = "517fe3ab6b63f9907b093bc9443ef06b56f804f3";
sha256 = "vXX9/5hulIlDwE9ISZlTMxxrl+Jjyquagv5+AHmEA5c=";
fetchSubmodules = false;
};
meta.homepage = "https://github.com/folke/lsp-colors.nvim";
};
in {
programs.neovim = {
enable = true;
vimAlias = true;
extraConfig = (builtins.replaceStrings [ "{{CLANGDPATH}}" "{{JLSPATH}}" ] [
"${pkgs.clang-tools}/bin/clangd"
"${pkgs.java-language-server}/bin/java-language-server"
] (builtins.readFile ./init.vim));
plugins = with pkgs.vimPlugins; [
editorconfig-vim
fzf-vim
gruvbox
meson
vim-airline
vim-clang-format
vim-fetch
vim-fish
vim-flatbuffers
vim-nftables
vim-nix
vim-protobuf
vim-sensible
vim-toml
nvim-lspconfig
nvim-compe
lsp-colors
];
};
home.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
home.packages = with pkgs; [
nixpkgs-fmt
python3
python3Packages.ipython
python3Packages.pylint
nodePackages.pyright
rust-analyzer
rnix-lsp
];
}

View file

@ -1,102 +0,0 @@
cnoremap w!! w !sudo tee > /dev/null %
autocmd vimenter * ++nested colorscheme gruvbox
set guifont=Fira\ Code:h11
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline_powerline_fonts = 1
set hidden
set nobackup
set nowritebackup
set cmdheight=2
set updatetime=300
set shortmess+=c
set signcolumn=yes
lua << EOF
-- Mostly stolen from https://github.com/breuerfelix/nixos/blob/e0c83e66e821d407efae3e998b8eb70b50f9f5e3/shell/vim/lsp.lua
local nvim_lsp = require('lspconfig')
local on_attach = function(client, bufnr)
local function buf_set_keymap(...) vim.api.nvim_buf_set_keymap(bufnr, ...) end
local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
local opts = { noremap = true, silent = true }
buf_set_keymap('n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
buf_set_keymap('n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
buf_set_keymap('n', 'gt', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
buf_set_keymap('n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
buf_set_keymap('n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
buf_set_keymap('n', '<leader>ra', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
buf_set_keymap('n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
buf_set_keymap('n', '<leader>rd', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
buf_set_keymap('n', '<leader>rh', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
buf_set_keymap('n', '<leader>rs', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
buf_set_keymap('n', '<leader>rk', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
buf_set_keymap('n', '<leader>rj', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
buf_set_keymap('n', '<leader>rl', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
-- Set some keybinds conditional on server capabilities
if client.resolved_capabilities.document_formatting then
buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.formatting()<CR>", opts)
elseif client.resolved_capabilities.document_range_formatting then
buf_set_keymap("n", "<leader>f", "<cmd>lua vim.lsp.buf.range_formatting()<CR>", opts)
end
-- Set autocommands conditional on server_capabilities
if client.resolved_capabilities.document_highlight then
vim.api.nvim_exec([[
hi LspReferenceRead cterm=bold ctermbg=red guibg=LightGrey
hi LspReferenceText cterm=bold ctermbg=red guibg=LightGrey
hi LspReferenceWrite cterm=bold ctermbg=red guibg=LightGrey
augroup lsp_document_highlight
autocmd! * <buffer>
autocmd CursorHold <buffer> lua vim.lsp.buf.document_highlight()
autocmd CursorMoved <buffer> lua vim.lsp.buf.clear_references()
augroup END
]], false)
end
end
nvim_lsp['pyright'].setup { on_attach = on_attach }
nvim_lsp['clangd'].setup {
on_attach = on_attach,
cmd = { "{{CLANGDPATH}}" }
}
nvim_lsp['java_language_server'].setup {
on_attach = on_attach,
cmd = { "{{JLSPATH}}" }
}
nvim_lsp['rust_analyzer'].setup { on_attach = on_attach }
nvim_lsp['rnix'].setup { on_attach = on_attach }
require'compe'.setup {
enabled = true;
autocomplete = true;
debug = false;
min_length = 1;
preselect = 'enable';
throttle_time = 80;
source_timeout = 200;
incomplete_delay = 400;
max_abbr_width = 100;
max_kind_width = 100;
max_menu_width = 100;
documentation = true;
source = {
path = true;
buffer = true;
calc = true;
nvim_lsp = true;
nvim_lua = true;
vsnip = false;
};
}
EOF

119
sets/nvim.nix Normal file
View file

@ -0,0 +1,119 @@
{ pkgs, ... }:
{
environment.sessionVariables = {
EDITOR = "nvim";
VISUAL = "nvim";
};
programs.nixvim = {
enable = true;
vimAlias = true;
# Basic editing / QoL
editorconfig.enable = true;
colorschemes.kanagawa.enable = true;
plugins = {
nix.enable = true;
airline = {
enable = true;
powerline = true;
theme = "dark";
};
};
globals = {
"airline#extensions#tabline#enabled" = 1;
"airline#extensions#tabline#formatter" = "unique_tail_improved";
};
extraPlugins = with pkgs.vimPlugins; [
vim-fetch
vim-fish
vim-flatbuffers
vim-nftables
vim-protobuf
vim-sensible
vim-toml
];
options = {
hidden = true;
backup = false;
writebackup = false;
cmdheight = 2;
updatetime = 300;
shortmess = "filnxtToOFc";
signcolumn = "yes";
number = true;
};
# LSP
plugins.rust-tools.enable = true;
plugins.lsp-format.enable = true;
plugins.lsp = {
enable = true;
servers = {
clangd.enable = true;
java-language-server.enable = true;
nil_ls.enable = true;
pylsp.enable = true;
};
keymaps = {
silent = true;
diagnostic = {
"<leader>rk" = "goto_prev";
"<leader>rj" = "goto_next";
};
lspBuf = {
K = "hover";
gD = "declaration";
gd = "definition";
gt = "type_definition";
gr = "references";
gi = "implementation";
"<leader>ra" = "code_action";
"<leader>rn" = "rename";
"<leader>rs" = "signature_help";
};
};
onAttach = ''
if client.server_capabilities.documentHighlightProvider then
vim.api.nvim_create_augroup("lsp_document_highlight", { clear = true })
vim.api.nvim_clear_autocmds { buffer = bufnr, group = "lsp_document_highlight" }
vim.api.nvim_create_autocmd("CursorHold", {
callback = vim.lsp.buf.document_highlight,
buffer = bufnr,
group = "lsp_document_highlight",
desc = "Document Highlight",
})
vim.api.nvim_create_autocmd("CursorMoved", {
callback = vim.lsp.buf.clear_references,
buffer = bufnr,
group = "lsp_document_highlight",
desc = "Clear All the References",
})
end
'';
};
# Autocomplete
plugins = {
nvim-cmp = {
enable = true;
sources = [
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "calc"; }
{ name = "emoji"; }
];
mappingPresets = [ "insert" "cmdline" ];
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<C-b>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<C-e>" = "cmp.mapping.abort()";
};
};
};
};
}

View file

@ -52,7 +52,6 @@
jq
libarchive
lsof
neovim
nix-index
openssl
p7zip

View file

@ -1,7 +1,8 @@
{ config, pkgs, ... }:
{
imports = [ ./sway.nix ./packages.nix ./pipewire.nix ./base.nix ../home ];
imports =
[ ./sway.nix ./packages.nix ./pipewire.nix ./base.nix ./nvim.nix ../home ];
i18n.defaultLocale = "de_DE.UTF-8";
i18n.supportedLocales = [ "all" ];