diff --git a/dotfiles/.config/niri/config.kdl b/dotfiles/.config/niri/config.kdl index e525b28..4b127df 100644 --- a/dotfiles/.config/niri/config.kdl +++ b/dotfiles/.config/niri/config.kdl @@ -1,6 +1,6 @@ input { disable-power-key-handling - focus-follows-mouse + focus-follows-mouse max-scroll-amount="0%" warp-mouse-to-focus mouse { diff --git a/home/nvim/default.nix b/home/nvim/default.nix index 2cfd401..c848d3e 100644 --- a/home/nvim/default.nix +++ b/home/nvim/default.nix @@ -3,27 +3,25 @@ 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 + black + ruff + google-java-format + jdt-language-server + prettierd + nodePackages.prettier + clang-tools + rustfmt + jq + yamlfmt + taplo + shfmt lua-language-server stylua + nixpkgs-fmt ]; plugins = with pkgs.vimPlugins; [ @@ -41,10 +39,7 @@ in { friendly-snippets gitsigns-nvim lualine-nvim - { - name = "neo-tree.nvim"; - path = neo-tree-nvim-main; - } + neo-tree-nvim neoconf-nvim neodev-nvim noice-nvim @@ -55,7 +50,6 @@ in { nvim-spectre nvim-treesitter nvim-treesitter-context - nvim-treesitter-textobjects nvim-ts-autotag nvim-ts-context-commentstring nvim-web-devicons @@ -199,7 +193,4 @@ in { # 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"; -} \ No newline at end of file +} diff --git a/home/nvim/lua/config/lazy.lua b/home/nvim/lua/config/lazy.lua index d73bfa1..343d042 100644 --- a/home/nvim/lua/config/lazy.lua +++ b/home/nvim/lua/config/lazy.lua @@ -1,53 +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 + 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", - }, - }, - }, + 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", + }, + }, + }, }) diff --git a/home/nvim/lua/config/options.lua b/home/nvim/lua/config/options.lua index 3ea1454..4ac5c1a 100644 --- a/home/nvim/lua/config/options.lua +++ b/home/nvim/lua/config/options.lua @@ -1,3 +1,4 @@ -- 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 +vim.g.autoformat = false \ No newline at end of file diff --git a/home/nvim/lua/plugins/format.lua b/home/nvim/lua/plugins/format.lua new file mode 100644 index 0000000..12813b8 --- /dev/null +++ b/home/nvim/lua/plugins/format.lua @@ -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, + }, +} diff --git a/home/nvim/lua/plugins/osc52.lua b/home/nvim/lua/plugins/osc52.lua index 7a20603..6b921cf 100644 --- a/home/nvim/lua/plugins/osc52.lua +++ b/home/nvim/lua/plugins/osc52.lua @@ -1,18 +1,18 @@ return { - "ojroques/nvim-osc52", - config = function() - require("osc52").setup { - max_length = 0, -- 不限制长度 - silent = false, - trim = false, - } + "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 + 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, + vim.api.nvim_create_autocmd("TextYankPost", { callback = copy }) + end, } diff --git a/home/nvim/lua/plugins/treesitter.lua b/home/nvim/lua/plugins/treesitter.lua new file mode 100644 index 0000000..805c2eb --- /dev/null +++ b/home/nvim/lua/plugins/treesitter.lua @@ -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, + }, +} \ No newline at end of file