Merge remote-tracking branch 'origin/nixos' into nixos

nixos
Moritz Böhme 2023-03-02 15:16:33 +01:00
commit 9db80c9673
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
8 changed files with 220 additions and 97 deletions

View File

@ -82,6 +82,22 @@
"type": "github"
}
},
"copilot-lua": {
"flake": false,
"locked": {
"lastModified": 1677479736,
"narHash": "sha256-n/SCrzzzL5WUHJk0sCXbgGusk/dQuy8DI9Pqdh+lVeQ=",
"owner": "zbirenbaum",
"repo": "copilot.lua",
"rev": "b41d4c9c7d4f5e0272bcf94061b88e244904c56f",
"type": "github"
},
"original": {
"owner": "zbirenbaum",
"repo": "copilot.lua",
"type": "github"
}
},
"crane": {
"inputs": {
"flake-compat": [
@ -496,6 +512,22 @@
"type": "github"
}
},
"lspsaga-nvim": {
"flake": false,
"locked": {
"lastModified": 1677497543,
"narHash": "sha256-xFba/hXqc0qyJH9Hd9XtXteXIqjJnIgYIy8Y5l9QPQQ=",
"owner": "glepnir",
"repo": "lspsaga.nvim",
"rev": "291629b704ba8fdd0134ef4204fb118050bca363",
"type": "github"
},
"original": {
"owner": "glepnir",
"repo": "lspsaga.nvim",
"type": "github"
}
},
"master": {
"locked": {
"lastModified": 1677259386,
@ -813,6 +845,7 @@
"arkenfox-userjs": "arkenfox-userjs",
"asus-touchpad-numpad-driver": "asus-touchpad-numpad-driver",
"attic": "attic",
"copilot-lua": "copilot-lua",
"emacs": "emacs",
"flake-utils": "flake-utils_3",
"forgit-git": "forgit-git",
@ -821,6 +854,7 @@
"hypr-contrib": "hypr-contrib",
"hyprland": "hyprland",
"hyprpaper": "hyprpaper",
"lspsaga-nvim": "lspsaga-nvim",
"master": "master",
"neovim": "neovim",
"nil": "nil",

View File

@ -77,6 +77,16 @@
flake = false;
};
copilot-lua = {
url = "github:zbirenbaum/copilot.lua";
flake = false;
};
lspsaga-nvim = {
url = "github:glepnir/lspsaga.nvim";
flake = false;
};
attic = {
url = "github:zhaofengli/attic";
inputs.nixpkgs.follows = "nixpkgs";

View File

@ -48,6 +48,7 @@ in
grep = "rg";
rm = "rm -i";
mv = "mv -i";
cd = "z";
nixos-switch = nom-system-command "sudo nixos-rebuild switch --flake ~/.dotfiles";
nixos-boot = nom-system-command "sudo nixos-rebuild boot --flake ~/.dotfiles";
@ -137,6 +138,7 @@ in
# Let Home Manager install and manage itself.
home-manager.enable = true;
fzf.enable = true;
zoxide.enable = true;
};
home = {
username = "moritz";

View File

@ -15,6 +15,24 @@ in
home-manager.users.moritz.programs.direnv = {
enable = true;
nix-direnv.enable = true;
stdlib = ''
layout_poetry() {
if [[ ! -f pyproject.toml ]]; then
log_error 'No pyproject.toml found. Use `poetry new` or `poetry init` to create one first.'
exit 2
fi
local VENV=$(poetry env info --path)
if [[ -z $VENV || ! -d $VENV/bin ]]; then
log_error 'No poetry virtual environment found. Use `poetry install` to create one first.'
exit 2
fi
export VIRTUAL_ENV=$VENV
export POETRY_ACTIVE=1
PATH_add "$VENV/bin"
}
'';
};
};
}

View File

@ -137,12 +137,13 @@ in
# Emacs
windowrulev2 = opaque, class:^emacs$
# Fullscreen Applications
# ${mkRules ["opaque" "noblur" "noborder" "noshadow" "forceinput"] ["fullscreen:1"]}
${mkRules ["opaque" "noblur" "noborder" "noshadow" "forceinput"] ["fullscreen:1"]}
${mkRules ["opaque" "noblur" "noshadow"] ["class:^jetbrains-pycharm$"]}
${mkRules ["tile" "opaque"] ["class:^neovide$"]}
# See https://wiki.hyprland.org/Configuring/Keywords/ for more
$mainMod = SUPER
$windowMod = ALT

View File

@ -8,26 +8,6 @@
with lib;
let
cfg = config.my.programs.vim;
mkDate = longDate: (lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
mkVersionInput = input: mkDate (input.lastModifiedDate or "19700101") + "_" + (input.shortRev or "dirty");
nvim-treesitter-textsubjects = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-treesitter-textsubjects";
version = mkVersionInput inputs.nvim-treesitter-textsubjects;
src = inputs.nvim-treesitter-textsubjects;
};
smartcolumn-nvim = pkgs.vimUtils.buildVimPluginFrom2Nix {
pname = "smartcolumn-nvim";
version = mkVersionInput inputs.smartcolumn-nvim;
src = inputs.smartcolumn-nvim;
};
in
{
options.my.programs.vim = {
@ -39,7 +19,16 @@ in
};
config = mkIf cfg.enable {
home-manager.users.moritz.programs.neovim = {
home-manager.users.moritz = {
home.packages = with pkgs; [
(
if config.my.programs.hyprland.enable
then neovide-hyprland
else neovide
)
];
programs.neovim = {
enable = true;
package = pkgs.neovim-nightly;
vimAlias = true;
@ -51,6 +40,7 @@ in
alejandra
black
isort
jq
nil
nixpkgs-fmt
rustfmt
@ -68,10 +58,12 @@ in
copilot-cmp
copilot-lua
dashboard-nvim
direnv-vim
formatter-nvim
gitsigns-nvim
lsp_lines-nvim
lspkind-nvim
lspsaga-nvim-original
lualine-lsp-progress
lualine-nvim
luasnip
@ -90,12 +82,15 @@ in
nvim-web-devicons # for dashboard-nvim
orgmode
plenary-nvim # for telescope, neogit
popup-nvim
smartcolumn-nvim
telescope-fzf-native-nvim
telescope-nvim
telescope-zoxide
vim-lion
which-key-nvim
];
};
};
};
}

View File

@ -12,7 +12,6 @@ vim.opt.backupdir = { vim.fn.stdpath("state") .. "/nvim/backup//" } -- don't sto
vim.opt.clipboard = "unnamedplus" -- sync with system clipboard
vim.opt.conceallevel = 2
vim.opt.expandtab = true -- spaces instead of tabs
vim.opt.guifont = "Fira Code Nerd Font:h1"
vim.opt.ignorecase = true
vim.opt.mouse = "a" -- mouse for all modes
vim.opt.number = true
@ -33,6 +32,11 @@ vim.opt.updatetime = 300
vim.opt_local.spell = true
vim.opt_local.spelllang = { "en", "de_20" } -- all English regions and new German spelling
if vim.g.neovide then
vim.opt.guifont = "Fira Code Nerd Font:h10"
vim.g.neovide_scale_factor = 0.7
end
require("catppuccin").setup({
compile_path = vim.fn.stdpath("cache") .. "/catppuccin", -- fix issue of writing to nix store
integrations = {
@ -67,10 +71,13 @@ require("noice").setup({
},
})
require("telescope").load_extension("zoxide")
wk.register({
f = {
name = "find",
f = { "<cmd>Telescope find_files<cr>", "find file" },
z = { "<cmd>Telescope zoxide list<cr>", "find location" },
l = { "<cmd>Telescope current_buffer_fuzzy_find<cr>", "find line" },
g = { "<cmd>Telescope live_grep<cr>", "live grep" },
b = { "<cmd>Telescope buffers<cr>", "find buffer" },
},
@ -186,11 +193,10 @@ require("formatter").setup({
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
-- Formatter configurations for filetype "lua" go here
-- and will be executed in order
json = {
require("formatter.filetypes.json").jq,
},
lua = {
-- "formatter.filetypes.lua" defines default configurations for the
-- "lua" filetype
require("formatter.filetypes.lua").stylua,
},
nix = {
@ -259,18 +265,25 @@ vim.diagnostic.config({
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = require("cmp_nvim_lsp").default_capabilities()
require("lspsaga").setup({
symbol_in_winbar = {
enable = false,
},
})
local lspconfig = require("lspconfig")
local on_attach_def = function(_, bufnr)
wk.register({
K = { vim.lsp.buf.hover, "show info" },
K = { "<cmd>Lspsaga hover_doc ++quiet<cr>", "show info" },
["<leader>"] = {
l = {
name = "lsp",
d = { vim.diagnostic.open_float, "open diagnostic window" },
n = { vim.diagnostic.goto_next, "next error" },
p = { vim.diagnostic.goto_prev, "prev error" },
c = { vim.lsp.buf.code_action, "code action" },
r = { vim.lsp.buf.rename, "rename" },
d = { "<cmd>Lspsaga show_cursor_diagnostics<cr>", "open diagnostic window" },
n = { "<cmd>Lspsaga diagnostic_jump_next<CR>", "next error" },
p = { "<cmd>Lspsaga diagnostic_jump_prev<CR>", "prev error" },
c = { "<cmd>Lspsaga code_action<cr>", "code action" },
r = { "<cmd>Lspsaga rename<cr>", "rename" },
i = { "<cmd>Lspsaga hover_doc ++keep<cr>", "show info (sticky)" },
f = {
function()
vim.lsp.buf.format({ async = true })
@ -297,11 +310,9 @@ local on_attach_def = function(_, bufnr)
},
g = {
name = "goto",
r = { vim.lsp.buf.references, "references" },
d = { vim.lsp.buf.definition, "definition" },
D = { vim.lsp.buf.declaration, "declaration" },
i = { vim.lsp.buf.implementation, "implementation" },
t = { vim.lsp.buf.type_definition, "type defininition" },
d = { "<cmd>Lspsaga peek_definition<cr>", "definition" },
t = { "<cmd>Lspsaga peek_type_definition<cr>", "type defininition" },
h = { "<cmd>Lspsaga lsp_finder<CR>", "lsp finder" },
},
}, { buffer = bufnr, silent = true })
end
@ -323,7 +334,7 @@ local function lspconfig_setup(lsp, options)
lspconfig[lsp].setup(final_options)
end
local servers = { "nil_ls", "pylsp", "rust_analyzer" }
local servers = { "nil_ls", "pylsp", "rust_analyzer", "ruff_lsp" }
for _, lsp in ipairs(servers) do
lspconfig_setup(lsp, {})
end
@ -360,7 +371,7 @@ lspconfig_setup("lua_ls", {
require("dashboard").setup({
theme = "hyper",
config = {
packages = { enable = true },
packages = { enable = false },
week_header = {
enable = true,
},
@ -434,6 +445,10 @@ require("copilot").setup({
suggestion = { enabled = false },
panel = { enabled = false },
})
vim.api.nvim_create_autocmd("VimEnter", {
desc = "Disable Copilot by default on startup",
command = "Copilot disable",
})
require("copilot_cmp").setup()
local orgmode = require("orgmode")
@ -478,4 +493,5 @@ wk.register({
require("smartcolumn").setup({
colorcolumn = 120,
disabled_filetypes = { "help", "text", "markdown", "dashboard" },
})

View File

@ -1,4 +1,14 @@
{ inputs }: final: prev: {
{ inputs }: final: prev:
let
mkDate = longDate: (prev.lib.concatStringsSep "-" [
(builtins.substring 0 4 longDate)
(builtins.substring 4 2 longDate)
(builtins.substring 6 2 longDate)
]);
mkVersionSrc = src: "unstable-" + builtins.substring 0 7 src.rev;
mkVersionInput = input: "unstable-" + mkDate (input.lastModifiedDate or "19700101") + "_" + (input.shortRev or "dirty");
in
{
agenix = inputs.agenix.packages.${prev.system}.default;
attic = inputs.attic.packages.${prev.system}.default;
hyprpaper = inputs.hyprpaper.packages.${prev.system}.default;
@ -23,6 +33,43 @@
mesonFlags = old.mesonFlags or [ ] ++ [ "-Dexperimental=true" ];
});
vimPlugins = prev.vimPlugins // {
nvim-treesitter-textsubjects = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "nvim-treesitter-textsubjects";
version = mkVersionInput inputs.nvim-treesitter-textsubjects;
src = inputs.nvim-treesitter-textsubjects;
};
smartcolumn-nvim = prev.vimUtils.buildVimPluginFrom2Nix {
pname = "smartcolumn-nvim";
version = mkVersionInput inputs.smartcolumn-nvim;
src = inputs.smartcolumn-nvim;
};
copilot-lua = prev.vimPlugins.copilot-lua.overrideAttrs (old: {
version = mkVersionInput inputs.copilot-lua;
src = inputs.copilot-lua;
});
lspsaga-nvim-original = prev.vimPlugins.lspsaga-nvim-original.overrideAttrs (old: {
version = mkVersionInput inputs.lspsaga-nvim;
src = inputs.lspsaga-nvim;
});
};
neovide-hyprland = final.symlinkJoin {
name = "neovide-hyprland-${final.neovide.version}";
paths = [ final.neovide ];
nativeBuildInputs = [ final.makeWrapper ];
postBuild = ''
rm $out/bin/neovide
makeWrapper ${final.neovide}/bin/neovide $out/bin/neovide --set WINIT_UNIX_BACKEND x11
'';
meta = final.neovide.meta // {
mainProgram = "neovide";
};
};
master = import inputs.master {
inherit (prev) system;
config.allowUnfree = true;