build:neotree

fix:highlight
fix:nvim_fmt
fix:stop_autofmt
fix:update_notice
fix:niri_scroll
This commit is contained in:
dichgrem
2025-11-14 16:58:48 +08:00
parent 02da5c19e2
commit e02cfc5dcd
7 changed files with 152 additions and 86 deletions

View File

@@ -1,6 +1,6 @@
input { input {
disable-power-key-handling disable-power-key-handling
focus-follows-mouse focus-follows-mouse max-scroll-amount="0%"
warp-mouse-to-focus warp-mouse-to-focus
mouse { mouse {

View File

@@ -3,27 +3,25 @@
lib, lib,
pkgs, 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 = { programs.neovim = {
enable = true; enable = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
# LazyVim black
ruff
google-java-format
jdt-language-server
prettierd
nodePackages.prettier
clang-tools
rustfmt
jq
yamlfmt
taplo
shfmt
lua-language-server lua-language-server
stylua stylua
nixpkgs-fmt
]; ];
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; [
@@ -41,10 +39,7 @@ in {
friendly-snippets friendly-snippets
gitsigns-nvim gitsigns-nvim
lualine-nvim lualine-nvim
{ neo-tree-nvim
name = "neo-tree.nvim";
path = neo-tree-nvim-main;
}
neoconf-nvim neoconf-nvim
neodev-nvim neodev-nvim
noice-nvim noice-nvim
@@ -55,7 +50,6 @@ in {
nvim-spectre nvim-spectre
nvim-treesitter nvim-treesitter
nvim-treesitter-context nvim-treesitter-context
nvim-treesitter-textobjects
nvim-ts-autotag nvim-ts-autotag
nvim-ts-context-commentstring nvim-ts-context-commentstring
nvim-web-devicons nvim-web-devicons
@@ -199,7 +193,4 @@ in {
# Normal LazyVim config here, see https://github.com/LazyVim/starter/tree/main/lua # Normal LazyVim config here, see https://github.com/LazyVim/starter/tree/main/lua
xdg.configFile."nvim/lua".source = ./lua; xdg.configFile."nvim/lua".source = ./lua;
}
# Set default editor
home.sessionVariables.EDITOR = "nvim";
}

View File

@@ -1,53 +1,53 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git" local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({ vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" }, { "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" }, { out, "WarningMsg" },
{ "\nPress any key to exit..." }, { "\nPress any key to exit..." },
}, true, {}) }, true, {})
vim.fn.getchar() vim.fn.getchar()
os.exit(1) os.exit(1)
end end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ require("lazy").setup({
spec = { spec = {
-- add LazyVim and import its plugins -- add LazyVim and import its plugins
{ "LazyVim/LazyVim", import = "lazyvim.plugins" }, { "LazyVim/LazyVim", import = "lazyvim.plugins" },
-- import/override with your plugins -- import/override with your plugins
{ import = "plugins" }, { import = "plugins" },
}, },
defaults = { defaults = {
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. -- 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. -- 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, lazy = false,
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning, -- 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. -- have outdated releases, which may break your Neovim install.
version = false, -- always use the latest git commit version = false, -- always use the latest git commit
-- version = "*", -- try installing the latest stable version for plugins that support semver -- version = "*", -- try installing the latest stable version for plugins that support semver
}, },
install = { colorscheme = { "tokyonight", "habamax" } }, install = { colorscheme = { "tokyonight", "habamax" } },
checker = { checker = {
enabled = true, -- check for plugin updates periodically enabled = true, -- check for plugin updates periodically
notify = false, -- notify on update notify = false, -- notify on update
}, -- automatically check for plugin updates }, -- automatically check for plugin updates
performance = { performance = {
rtp = { rtp = {
-- disable some rtp plugins -- disable some rtp plugins
disabled_plugins = { disabled_plugins = {
"gzip", "gzip",
-- "matchit", -- "matchit",
-- "matchparen", -- "matchparen",
-- "netrwPlugin", -- "netrwPlugin",
"tarPlugin", "tarPlugin",
"tohtml", "tohtml",
"tutor", "tutor",
"zipPlugin", "zipPlugin",
}, },
}, },
}, },
}) })

View File

@@ -1,3 +1,4 @@
-- Options are automatically loaded before lazy.nvim startup -- 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 -- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
-- Add any additional options here -- Add any additional options here
vim.g.autoformat = false

View File

@@ -0,0 +1,44 @@
return {
{
"stevearc/conform.nvim",
opts = function(_, opts)
opts.format_on_save = nil
opts.formatters = opts.formatters or {}
opts.formatters.nixpkgs_fmt = {
command = "nixpkgs-fmt",
args = function(ctx)
return {}
end,
stdin = true,
exit_codes = { 0 },
}
opts.formatters_by_ft = opts.formatters_by_ft or {}
opts.formatters_by_ft.nix = { "nixpkgs_fmt", stop_after_first = true }
opts.formatters_by_ft.lua = { "stylua" }
opts.formatters_by_ft.python = { "black", "ruff_format" }
opts.formatters_by_ft.sh = { "shfmt" }
opts.formatters_by_ft.javascript = { "prettier" }
opts.formatters_by_ft.typescript = { "prettier" }
opts.formatters_by_ft.javascriptreact = { "prettier" }
opts.formatters_by_ft.typescriptreact = { "prettier" }
opts.formatters_by_ft.vue = { "prettier" }
opts.formatters_by_ft.go = { "gofmt" }
opts.formatters_by_ft.c = { "clang_format" }
opts.formatters_by_ft.cpp = { "clang_format" }
opts.formatters_by_ft.rust = { "rustfmt" }
opts.formatters_by_ft.java = { "google-java-format" }
opts.formatters_by_ft.json = { "jq" }
opts.formatters_by_ft.yaml = { "yamlfmt" }
opts.formatters_by_ft.toml = { "taplo" }
opts.default_format_opts = {
timeout_ms = 1000,
lsp_format = "fallback",
stop_after_first = false,
}
opts.log_level = vim.log.levels.ERROR
opts.notify_on_error = true
opts.notify_no_formatters = true
return opts
end,
},
}

View File

@@ -1,18 +1,18 @@
return { return {
"ojroques/nvim-osc52", "ojroques/nvim-osc52",
config = function() config = function()
require("osc52").setup { require("osc52").setup({
max_length = 0, -- 不限制长度 max_length = 0, -- 不限制长度
silent = false, silent = false,
trim = false, trim = false,
} })
local function copy() local function copy()
if vim.v.event.operator == "y" and vim.v.event.regname == "" then if vim.v.event.operator == "y" and vim.v.event.regname == "" then
require("osc52").copy_register("") require("osc52").copy_register("")
end end
end end
vim.api.nvim_create_autocmd("TextYankPost", { callback = copy }) vim.api.nvim_create_autocmd("TextYankPost", { callback = copy })
end, end,
} }

View File

@@ -0,0 +1,30 @@
return {
{
"LazyVim/LazyVim",
opts = {
treesitter = false,
},
},
{
"nvim-treesitter/nvim-treesitter",
event = { "BufReadPost", "BufNewFile" },
opts = {
ensure_installed = {},
auto_install = false,
highlight = { enable = true },
indent = { enable = true },
incremental_selection = {
enable = true,
keymaps = {
init_selection = "gnn",
node_incremental = "grn",
scope_incremental = "grc",
node_decremental = "grm",
},
},
},
config = function(_, opts)
require("nvim-treesitter.configs").setup(opts)
end,
},
}