mirror of
https://github.com/Dichgrem/DCGOS.git
synced 2025-12-16 19:22:00 -05:00
feat:add_neovim
build:update_flake
This commit is contained in:
@@ -8,11 +8,13 @@
|
||||
ls = lib.filesystem.listFilesRecursive;
|
||||
in {
|
||||
imports =
|
||||
ls ./cli
|
||||
[
|
||||
./nvim/default.nix
|
||||
]
|
||||
++ ls ./cli
|
||||
++ ls ./gui
|
||||
++ ls ./tui
|
||||
++ ls ./wayland;
|
||||
|
||||
home = {
|
||||
file = {
|
||||
".config" = {
|
||||
|
||||
205
home/nvim/default.nix
Normal file
205
home/nvim/default.nix
Normal file
@@ -0,0 +1,205 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
neo-tree-nvim-main = pkgs.vimUtils.buildVimPlugin {
|
||||
pname = "neo-tree-nvim-main";
|
||||
version = "3.35.2+6";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "nvim-neo-tree";
|
||||
repo = "neo-tree.nvim";
|
||||
rev = "8dd9f08ff086d09d112f1873f88dc0f74b598cdb";
|
||||
sha256 = "sha256-edthaqznGTJ+VFVORK7gfHI9J14PLAghG9prsWlzXtc=";
|
||||
};
|
||||
doCheck = false;
|
||||
meta.homepage = "https://github.com/nvim-neo-tree/neo-tree.nvim/";
|
||||
meta.hydraPlatforms = [];
|
||||
};
|
||||
in {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
extraPackages = with pkgs; [
|
||||
# LazyVim
|
||||
lua-language-server
|
||||
stylua
|
||||
];
|
||||
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
lazy-nvim
|
||||
];
|
||||
|
||||
extraLuaConfig = let
|
||||
plugins = with pkgs.vimPlugins; [
|
||||
LazyVim
|
||||
bufferline-nvim
|
||||
cmp_luasnip
|
||||
conform-nvim
|
||||
dashboard-nvim
|
||||
flash-nvim
|
||||
friendly-snippets
|
||||
gitsigns-nvim
|
||||
lualine-nvim
|
||||
{
|
||||
name = "neo-tree.nvim";
|
||||
path = neo-tree-nvim-main;
|
||||
}
|
||||
neoconf-nvim
|
||||
neodev-nvim
|
||||
noice-nvim
|
||||
nui-nvim
|
||||
nvim-lint
|
||||
nvim-lspconfig
|
||||
nvim-notify
|
||||
nvim-spectre
|
||||
nvim-treesitter
|
||||
nvim-treesitter-context
|
||||
nvim-treesitter-textobjects
|
||||
nvim-ts-autotag
|
||||
nvim-ts-context-commentstring
|
||||
nvim-web-devicons
|
||||
persistence-nvim
|
||||
plenary-nvim
|
||||
todo-comments-nvim
|
||||
tokyonight-nvim
|
||||
trouble-nvim
|
||||
vim-illuminate
|
||||
vim-startuptime
|
||||
which-key-nvim
|
||||
fzf-lua
|
||||
snacks-nvim
|
||||
{
|
||||
name = "lazydev.nvim";
|
||||
path = lazydev-nvim;
|
||||
}
|
||||
{
|
||||
name = "blink.cmp";
|
||||
path = blink-cmp;
|
||||
}
|
||||
{
|
||||
name = "LuaSnip";
|
||||
path = luasnip;
|
||||
}
|
||||
{
|
||||
name = "mini.ai";
|
||||
path = mini-nvim;
|
||||
}
|
||||
{
|
||||
name = "mini.bufremove";
|
||||
path = mini-nvim;
|
||||
}
|
||||
{
|
||||
name = "mini.comment";
|
||||
path = mini-nvim;
|
||||
}
|
||||
{
|
||||
name = "mini.indentscope";
|
||||
path = mini-nvim;
|
||||
}
|
||||
{
|
||||
name = "mini.pairs";
|
||||
path = mini-nvim;
|
||||
}
|
||||
{
|
||||
name = "mini.surround";
|
||||
path = mini-nvim;
|
||||
}
|
||||
{
|
||||
name = "mini.icons";
|
||||
path = mini-icons;
|
||||
}
|
||||
{
|
||||
name = "grug-far.nvim";
|
||||
path = grug-far-nvim;
|
||||
}
|
||||
];
|
||||
mkEntryFromDrv = drv:
|
||||
if lib.isDerivation drv
|
||||
then {
|
||||
name = "${lib.getName drv}";
|
||||
path = drv;
|
||||
}
|
||||
else drv;
|
||||
lazyPath = pkgs.linkFarm "lazy-plugins" (builtins.map mkEntryFromDrv plugins);
|
||||
in ''
|
||||
require("lazy").setup({
|
||||
defaults = {
|
||||
lazy = true,
|
||||
},
|
||||
dev = {
|
||||
-- reuse files from pkgs.vimPlugins.*
|
||||
path = "${lazyPath}",
|
||||
patterns = { "." },
|
||||
-- fallback to download
|
||||
fallback = true,
|
||||
},
|
||||
rocks = {
|
||||
enabled = false,
|
||||
hererocks = false,
|
||||
},
|
||||
spec = {
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- The following configs are needed for fixing lazyvim on nix
|
||||
-- disable mason.nvim, use programs.neovim.extraPackages
|
||||
{ "mason-org/mason-lspconfig.nvim", enabled = false },
|
||||
{ "mason-org/mason.nvim", enabled = false },
|
||||
-- import/override with your plugins
|
||||
{ import = "lazyvim.plugins.extras.lang.go" },
|
||||
{ import = "lazyvim.plugins.extras.lang.clangd" },
|
||||
{ import = "lazyvim.plugins.extras.lang.rust" },
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
{ import = "lazyvim.plugins.extras.lang.python" },
|
||||
{ import = "lazyvim.plugins.extras.lang.tailwind" },
|
||||
{ import = "lazyvim.plugins.extras.lang.java" },
|
||||
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||
{ import = "lazyvim.plugins.extras.lang.yaml" },
|
||||
{ import = "lazyvim.plugins.extras.lang.toml" },
|
||||
{ import = "lazyvim.plugins.extras.lang.docker" },
|
||||
{ import = "plugins" },
|
||||
-- treesitter handled by xdg.configFile."nvim/parser", put this line at the end of spec to clear ensure_installed
|
||||
{ "nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = {}
|
||||
end,
|
||||
},
|
||||
},
|
||||
})
|
||||
'';
|
||||
};
|
||||
|
||||
# https://github.com/nvim-treesitter/nvim-treesitter#i-get-query-error-invalid-node-type-at-position
|
||||
xdg.configFile."nvim/parser".source = let
|
||||
parsers = pkgs.symlinkJoin {
|
||||
name = "treesitter-parsers";
|
||||
paths =
|
||||
(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins:
|
||||
with plugins; [
|
||||
bash
|
||||
c
|
||||
lua
|
||||
python
|
||||
go
|
||||
rust
|
||||
java
|
||||
javascript
|
||||
typescript
|
||||
tsx
|
||||
vue
|
||||
html
|
||||
css
|
||||
json
|
||||
yaml
|
||||
toml
|
||||
dockerfile
|
||||
]))
|
||||
.dependencies;
|
||||
};
|
||||
in "${parsers}/parser";
|
||||
|
||||
# Normal LazyVim config here, see https://github.com/LazyVim/starter/tree/main/lua
|
||||
xdg.configFile."nvim/lua".source = ./lua;
|
||||
|
||||
# Set default editor
|
||||
home.sessionVariables.EDITOR = "nvim";
|
||||
}
|
||||
8
home/nvim/lua/config/autocmds.lua
Normal file
8
home/nvim/lua/config/autocmds.lua
Normal file
@@ -0,0 +1,8 @@
|
||||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
--
|
||||
-- Add any additional autocmds here
|
||||
-- with `vim.api.nvim_create_autocmd`
|
||||
--
|
||||
-- Or remove existing autocmds by their group name (which is prefixed with `lazyvim_` for the defaults)
|
||||
-- e.g. vim.api.nvim_del_augroup_by_name("lazyvim_wrap_spell")
|
||||
31
home/nvim/lua/config/keymaps.lua
Normal file
31
home/nvim/lua/config/keymaps.lua
Normal file
@@ -0,0 +1,31 @@
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
-- Add any additional keymaps here
|
||||
|
||||
local map = vim.keymap.set
|
||||
local opts = { noremap = true, silent = true }
|
||||
|
||||
-- === VSCode-like buffer/tab navigation ===
|
||||
map("n", "<C-Tab>", "<cmd>bnext<CR>", { desc = "Next buffer (like VSCode)" })
|
||||
map("n", "<C-S-Tab>", "<cmd>bprevious<CR>", { desc = "Previous buffer (like VSCode)" })
|
||||
|
||||
-- === Close buffer like Ctrl + W in VSCode ===
|
||||
vim.keymap.set("n", "<C-w>", "<cmd>BufferLinePickClose<CR>", { desc = "Close buffer (BufferLine)" })
|
||||
|
||||
vim.keymap.set("n", "<C-S-5>", function()
|
||||
if vim.bo.buftype == "terminal" then
|
||||
vim.cmd("vsplit | terminal")
|
||||
else
|
||||
vim.cmd("botright split | terminal")
|
||||
end
|
||||
end, { desc = "Split terminal" })
|
||||
|
||||
-- 在终端模式下的快捷键
|
||||
vim.keymap.set("t", "<C-h>", "<C-\\><C-n><C-w>h", { desc = "Go to left window" })
|
||||
vim.keymap.set("t", "<C-j>", "<C-\\><C-n><C-w>j", { desc = "Go to lower window" })
|
||||
vim.keymap.set("t", "<C-k>", "<C-\\><C-n><C-w>k", { desc = "Go to upper window" })
|
||||
vim.keymap.set("t", "<C-l>", "<C-\\><C-n><C-w>l", { desc = "Go to right window" })
|
||||
|
||||
vim.keymap.set("n", "<leader>xo", function()
|
||||
vim.fn.jobstart({ "xdg-open", vim.fn.expand("%:p") }, { detach = true })
|
||||
end, { desc = "使用系统默认应用程序打开当前文件" })
|
||||
53
home/nvim/lua/config/lazy.lua
Normal file
53
home/nvim/lua/config/lazy.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
-- import/override with your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
},
|
||||
install = { colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = {
|
||||
enabled = true, -- check for plugin updates periodically
|
||||
notify = false, -- notify on update
|
||||
}, -- automatically check for plugin updates
|
||||
performance = {
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
"tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
3
home/nvim/lua/config/options.lua
Normal file
3
home/nvim/lua/config/options.lua
Normal file
@@ -0,0 +1,3 @@
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
16
home/nvim/lua/plugins/colorscheme.lua
Normal file
16
home/nvim/lua/plugins/colorscheme.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
{
|
||||
"folke/tokyonight.nvim",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
opts = {
|
||||
style = "storm",
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("tokyonight").setup(opts)
|
||||
vim.defer_fn(function()
|
||||
vim.cmd([[colorscheme tokyonight]])
|
||||
end, 0)
|
||||
end,
|
||||
},
|
||||
}
|
||||
18
home/nvim/lua/plugins/dashboard.lua
Normal file
18
home/nvim/lua/plugins/dashboard.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- ~/.config/nvim/lua/plugins/dashboard.lua
|
||||
return {
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
dashboard = {
|
||||
preset = {
|
||||
header = [[
|
||||
███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗
|
||||
████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║
|
||||
██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║
|
||||
██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║
|
||||
██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||
]],
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
18
home/nvim/lua/plugins/osc52.lua
Normal file
18
home/nvim/lua/plugins/osc52.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
return {
|
||||
"ojroques/nvim-osc52",
|
||||
config = function()
|
||||
require("osc52").setup {
|
||||
max_length = 0, -- 不限制长度
|
||||
silent = false,
|
||||
trim = false,
|
||||
}
|
||||
|
||||
local function copy()
|
||||
if vim.v.event.operator == "y" and vim.v.event.regname == "" then
|
||||
require("osc52").copy_register("")
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
|
||||
end,
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{pkgs, ...}: {
|
||||
home.packages = with pkgs; [
|
||||
neovim
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user