[feat] Add easy way to switch between lazy.nvim vs nixneovim

This commit is contained in:
Uttarayan Mondal
2024-02-28 20:46:33 +05:30
parent 186af6d51e
commit 461962ffbd
3 changed files with 173 additions and 76 deletions

View File

@@ -2,14 +2,15 @@
let let
start-tmux = (import ../scripts/start-tmux.nix) pkgs; start-tmux = (import ../scripts/start-tmux.nix) pkgs;
# https://mipmip.github.io/home-manager-option-search/ # https://mipmip.github.io/home-manager-option-search/
in { lazy = true;
in
{
imports = [ imports = [
# Include the results of the hardware scan. # Include the results of the hardware scan.
./tmux.nix ./tmux.nix
./wezterm.nix ./wezterm.nix
./nvim.nix ] ++ (if device.isLinux then [ ../linux ] else [ ])
++ (if !lazy then [ ./nvim ] else [ ]);
] ++ (if device.isLinux then [ ../linux ] else [ ]);
home.packages = with pkgs; home.packages = with pkgs;
[ [
@@ -38,6 +39,7 @@ in {
neovim-nightly neovim-nightly
nil nil
pkg-config pkg-config
lua-language-server
# neovim # neovim
(nerdfonts.override { fonts = [ "Hasklig" ]; }) (nerdfonts.override { fonts = [ "Hasklig" ]; })
mpv mpv
@@ -121,17 +123,19 @@ in {
enable = true; enable = true;
enableFishIntegration = true; enableFishIntegration = true;
enableNushellIntegration = true; enableNushellIntegration = true;
settings = let flavour = "mocha"; # Replace with your preferred palette settings =
in { let flavour = "mocha"; # Replace with your preferred palette
# Other config here in {
format = "$all"; # Remove this line to disable the default prompt format # Other config here
palette = "catppuccin_${flavour}"; format = "$all"; # Remove this line to disable the default prompt format
} // builtins.fromTOML (builtins.readFile (pkgs.fetchFromGitHub { palette = "catppuccin_${flavour}";
owner = "catppuccin"; } // builtins.fromTOML (builtins.readFile (pkgs.fetchFromGitHub
repo = "starship"; {
rev = "main"; # Replace with the latest commit hash owner = "catppuccin";
sha256 = "sha256-nsRuxQFKbQkyEI4TXgvAjcroVdG+heKX5Pauq/4Ota0"; repo = "starship";
} + /palettes/${flavour}.toml)); rev = "main"; # Replace with the latest commit hash
sha256 = "sha256-nsRuxQFKbQkyEI4TXgvAjcroVdG+heKX5Pauq/4Ota0";
} + /palettes/${flavour}.toml));
}; };
eza = { eza = {
enable = true; enable = true;
@@ -159,16 +163,17 @@ in {
enable = true; enable = true;
config = { theme = "catppuccin"; }; config = { theme = "catppuccin"; };
themes = { themes = {
catppuccin = let flavor = "mocha"; catppuccin =
in { let flavor = "mocha";
src = pkgs.fetchFromGitHub { in {
owner = "catppuccin"; src = pkgs.fetchFromGitHub {
repo = "bat"; owner = "catppuccin";
rev = "main"; repo = "bat";
sha256 = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw"; rev = "main";
sha256 = "sha256-6WVKQErGdaqb++oaXnY3i6/GuH2FhTgK0v4TN4Y0Wbw";
};
file = "Catppuccin-${flavor}.tmTheme";
}; };
file = "Catppuccin-${flavor}.tmTheme";
};
}; };
}; };
@@ -181,17 +186,16 @@ in {
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
username = device.user; username = device.user;
homeDirectory = if device.isMac then homeDirectory =
lib.mkForce "/Users/${device.user}" if device.isMac then
else lib.mkForce "/Users/${device.user}"
lib.mkForce "/home/${device.user}"; else
lib.mkForce "/home/${device.user}";
stateVersion = "23.11"; stateVersion = "23.11";
file = { file = {
".config/tmux/sessions".source = ../../tmux/sessions; ".config/tmux/sessions".source = ../../tmux/sessions;
# ".config/nvim/lua".source = ../../nvim/lua;
# ".config/nvim/init.lua".source = ../../nvim/init.lua;
".config/macchina".source = ../../macchina; ".config/macchina".source = ../../macchina;
# # You can also set the file content immediately. # # You can also set the file content immediately.
@@ -199,7 +203,10 @@ in {
# org.gradle.console=verbose # org.gradle.console=verbose
# org.gradle.daemon.idletimeout=3600000 # org.gradle.daemon.idletimeout=3600000
# ''; # '';
}; } // (if lazy then {
".config/nvim/lua".source = ../../nvim/lua;
".config/nvim/init.lua".source = ../../nvim/init.lua;
} else { });
sessionVariables = { sessionVariables = {
EDITOR = "nvim"; EDITOR = "nvim";

View File

@@ -1,4 +1,4 @@
{ pkgs, inputs, ... }: { { pkgs, config, inputs, ... }: {
imports = [ inputs.nixneovim.nixosModules.default ]; imports = [ inputs.nixneovim.nixosModules.default ];
programs.nixneovim = { programs.nixneovim = {
enable = true; enable = true;
@@ -15,13 +15,14 @@
smartcase = true; smartcase = true;
termguicolors = true; termguicolors = true;
signcolumn = "yes"; signcolumn = "yes";
# "opt.list" = true;
wrap = true; wrap = true;
completeopt = "menu,menuone,popup,noselect";
undodir = "${config.xdg.cacheHome}/undodir";
undofile = true;
}; };
globals = { globals = {
mapleader = " "; mapleader = " ";
#copilot_no_tab_map = true;
}; };
plugins = { plugins = {
lspconfig = { lspconfig = {
@@ -44,52 +45,58 @@
}, },
''; '';
}; };
lua-language-server = { lua-language-server = { enable = true; };
enable = true;
onAttachExtra = ''
local lspconfig = require 'lspconfig'
local lsp_zero = require'lsp-zero'
local lua_opts = lsp_zero.nvim_lua_ls()
lspconfig.lua_ls.setup(lua_opts)
'';
};
}; };
onAttach = '' extraLua.pre = ''
vim.lsp.inlay_hint.enable(bufnr, true) local lsp_zero = require'lsp-zero'
local lspconfig = require 'lspconfig'
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({buffer = bufnr})
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(bufnr, true)
end
end)
''; '';
# extraLua.post = ''
# vim.lsp.inlay_hint.enable(bufnr, true)
# '';
}; };
todo-comments.enable = true; todo-comments.enable = true;
lualine.enable = true; lualine.enable = true;
commentary.enable = true; commentary.enable = true;
surround.enable = true; surround.enable = true;
which-key.enable = true;
treesitter = { treesitter = {
enable = true; enable = true;
indent = true; indent = true;
}; };
telescope = {
enable = true;
extensions = {
manix.enable = true;
# plenary.enable = true;
};
};
nvim-cmp = { nvim-cmp = {
enable = true; enable = true;
completion = { completion = { completeopt = "menu,menuone,popup,noselect"; };
completeopt = "menu,menuone,popup,noselect"; window = {
completion = { border = "rounded"; };
documentation = { border = "rounded"; };
}; };
sources = { sources = {
nvim_lsp.enable = true; nvim_lsp.enable = true;
luasnip.enable = true; luasnip.enable = true;
buffer.enable = true; buffer.enable = true;
path.enable = true; path.enable = true;
cmdline.enable = true;
#copilot.enable = true;
git.enable = true; git.enable = true;
cmdline.enable = true;
}; };
mappingPresets = [ "insert" ];
mapping = {
"<CR>" = "cmp.mapping.confirm({ select = true })";
"<C-y>" = "cmp.mapping.complete()";
"<C-n>" = "cmp.config.next";
"<C-p>" = "cmp.config.prev";
};
snippet.luasnip.enable = true; snippet.luasnip.enable = true;
}; };
@@ -104,35 +111,44 @@
normal = { normal = {
"<leader>ff" = "require'telescope.builtin'.find_files"; "<leader>ff" = "require'telescope.builtin'.find_files";
"<leader>gg" = "require'telescope.builtin'.live_grep"; "<leader>gg" = "require'telescope.builtin'.live_grep";
"<leader>mm" = "require'telescope-manix'.search";
"<leader>;" = "require'telescope.builtin'.buffers"; "<leader>;" = "require'telescope.builtin'.buffers";
"<leader>\\\"" = ''[["+]]'';
"<leader><leader>" = "'<c-^>'"; "<leader><leader>" = "'<c-^>'";
"vff" = "'<cmd>vertical Gdiffsplit<cr>'"; "vff" = "'<cmd>vertical Gdiffsplit<cr>'";
"<C-k>" = "vim.lsp.buf.definition"; "<C-k>" = "vim.lsp.buf.definition";
"gi" = "vim.lsp.buf.implementation"; "gi" = "vim.lsp.buf.implementation";
"<leader>a" = "vim.lsp.buf.code_action"; "<leader>a" = "vim.lsp.buf.code_action";
"F" = "function() vim.lsp.buf.format({ async = true }) end"; "F" = "function() vim.lsp.buf.format({ async = true }) end";
# "<C-l>" = ''copilot#Accept("<CR>")''; "<C-l>" = "'copilot#Accept(\"<CR>\")'";
"<leader>q" = "[[<cmd>bw<cr>]]";
"<leader>n" = "[[<cmd>bnext<cr>]]";
"<leader>p" = "[[<cmd>bprev<cr>]]";
}; };
}; };
extraPlugins = extraPlugins = let
let comfortable-motion = pkgs.fetchFromGitHub {
comfortable-motion = pkgs.fetchFromGitHub { owner = "yuttie";
owner = "yuttie"; repo = "comfortable-motion.vim";
repo = "comfortable-motion.vim"; rev = "master";
rev = "master"; sha256 = "sha256-S1LJXmShhpCJIg/FEPx3jFbmPpS/1U4MAQN2RY/nkI0";
sha256 = "sha256-S1LJXmShhpCJIg/FEPx3jFbmPpS/1U4MAQN2RY/nkI0"; };
}; in [
in comfortable-motion
[ pkgs.vimPlugins.vim-abolish
comfortable-motion pkgs.vimPlugins.telescope-nvim
pkgs.vimExtraPlugins.rustaceanvim pkgs.vimPlugins.telescope-ui-select-nvim
pkgs.vimExtraPlugins.cmp-nvim-lsp pkgs.vimPlugins.telescope-fzf-native-nvim
pkgs.vimExtraPlugins.fidget-nvim pkgs.vimPlugins.telescope-file-browser-nvim
pkgs.vimExtraPlugins.rest-nvim pkgs.vimExtraPlugins.rustaceanvim
pkgs.vimExtraPlugins.lsp-zero-nvim pkgs.vimExtraPlugins.cmp-nvim-lsp
pkgs.vimPlugins.vim-abolish pkgs.vimExtraPlugins.fidget-nvim
]; pkgs.vimExtraPlugins.copilot-lua
pkgs.vimExtraPlugins.lsp-zero-nvim
pkgs.vimExtraPlugins.rest-nvim
];
extraConfigLua = builtins.readFile ./extraConfig.lua;
package = pkgs.neovim-nightly;
}; };
} }

View File

@@ -0,0 +1,74 @@
vim.g.rustaceanvim = {
server = {
on_attach = function(client, bufnr)
if client.server_capabilities.inlayHintProvider then
vim.lsp.inlay_hint.enable(bufnr, true)
end
end,
},
dap = {
autoload_configurations = false
},
}
require("copilot").setup({
suggestion = {
enabled = true,
auto_trigger = true,
keymap = {
accept = "<C-l>",
}
},
panel = { enabled = true },
})
require 'fidget'.setup()
local cmp = require 'cmp'
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline {
['<C-n>'] = cmp.config.disable,
['<C-p>'] = cmp.config.disable,
},
sources = {
{ name = 'buffer' }
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline {
['<C-n>'] = cmp.config.disable,
['<C-p>'] = cmp.config.disable,
},
-- mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
require('telescope').setup {
defaults = {
initial_mode = 'insert',
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
override_generic_sorter = true, -- override the generic sorter
override_file_sorter = true, -- override the file sorter
case_mode = "smart_case", -- or "ignore_case" or "respect_case"
}
}
}
require("telescope").load_extension("ui-select")
require('telescope').load_extension("fzf")
require('telescope').load_extension("file_browser")