diff --git a/nvim/init.lua b/nvim/init.lua index 119e9cf..cb2901e 100644 --- a/nvim/init.lua +++ b/nvim/init.lua @@ -242,10 +242,6 @@ elseif vim.fn.isdirectory(XDG_CONFIG_HOME .. "/nvim/venv/") then vim.g.python3_host_prog = XDG_CONFIG_HOME .. "/nvim/venv/bin/python" end --- Example for configuring Neovim to load user-installed installed Lua rocks: -package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua;" -package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua;" - -- lazy bootstrap local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not vim.loop.fs_stat(lazypath) then diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index b579406..c4858d7 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -24,6 +24,51 @@ return { -- A plugin for fancy fonts. { "nvim-tree/nvim-web-devicons", default = true }, + { + "nvim-mini/mini.files", + version = false, + config = function() + require("mini.files").setup() + vim.keymap.set( + "n", + "b", + ":lua require('mini.files').open(vim.fn.expand('%:p:h'))", + { silent = true } + ) + end, + }, + + { + "nvim-mini/mini.diff", + config = function() + local diff = require("mini.diff") + diff.setup({ + -- Disabled by default + source = diff.gen_source.none(), + }) + end, + }, + + { + "nvim-mini/mini.surround", + config = function() + require("mini.surround").setup() + end, + }, + + { + "nvim-mini/mini.indentscope", + config = function() + require("mini.indentscope").setup() + end, + }, + + -- EditorConfig plugin. + { "editorconfig/editorconfig-vim" }, + + -- A comment-out plugin. + { "tpope/vim-commentary" }, + -- Language Server config. { "neovim/nvim-lspconfig", @@ -67,7 +112,6 @@ return { end -- Setup LSP servers. - -- if vim.fn.executable("terraform-ls") ~= 0 then lspconfig.terraformls.setup(opts) end @@ -76,11 +120,18 @@ return { lspconfig.solargraph.setup(opts) end + local has_ruff = vim.fn.executable("ruff-lsp") ~= 0 + if has_ruff then + lspconfig.ruff_lsp.setup(opts) + end if vim.fn.executable("pyright") ~= 0 then local pythonPath = vim.fn.system("which python") opts["python"] = { pythonPath = pythonPath, } + opts["pyright"] = { + disableOrganizeImports = has_ruff, + } lspconfig.pyright.setup(opts) end @@ -124,6 +175,43 @@ return { end, }, + { + "kosayoda/nvim-lightbulb", + config = function() + require("nvim-lightbulb").setup({ + autocmd = { enabled = true }, + -- 行番号ではなく行末に出す + sign = { enabled = false }, + virtual_text = { enabled = true }, + }) + end, + }, + + { + "aznhe21/actions-preview.nvim", + config = function() + require("actions-preview").setup({ + -- バックエンドに使うプラグインの優先順位。デフォルトではtelescopeを優先的に使う + -- backend = { "nui", "telescope" }, + -- telescopeで表示する場合の設定。ウィンドウ小さめでもいい感じに出す + telescope = { + sorting_strategy = "ascending", + layout_strategy = "vertical", + layout_config = { + width = 0.8, + height = 0.9, + prompt_position = "top", + preview_cutoff = 20, + preview_height = function(_, _, max_lines) + return max_lines - 15 + end, + }, + }, + }) + vim.keymap.set("n", "gf", require("actions-preview").code_actions, { buffer = bufnr, silent = true }) + end, + }, + ---- noice.nvim { "folke/noice.nvim", @@ -261,117 +349,27 @@ return { }, { - "MeanderingProgrammer/render-markdown.nvim", - dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.icons" }, - ft = { "codecompanion" }, - opts = { - file_types = { "codecompanion" }, - }, - }, - - { - "echasnovski/mini.diff", - config = function() - local diff = require("mini.diff") - diff.setup({ - -- Disabled by default - source = diff.gen_source.none(), - }) - end, - }, - - { - "Davidyz/VectorCode", - version = "*", - dependencies = { "nvim-lua/plenary.nvim" }, - }, - - { - "ravitemer/mcphub.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - }, - build = "bundled_build.lua", -- Bundles `mcp-hub` binary along with the neovim plugin - config = function() - require("mcphub").setup({ - use_bundled_binary = true, -- Use local `mcp-hub` binary - }) - end, - }, - - { - "olimorris/codecompanion.nvim", - dependencies = { - "echasnovski/mini.diff", - "ravitemer/mcphub.nvim", - "banjo/contextfiles.nvim", - "nvim-lua/plenary.nvim", - "nvim-treesitter/nvim-treesitter", - }, + "coder/claudecode.nvim", + dependencies = { "folke/snacks.nvim" }, + config = true, keys = { - { "aa", ":CodeCompanionChat toggle", mode = { "n", "v" }, noremap = true, silent = true }, - { "ae", ":CodeCompanionActions", mode = { "n", "v" }, noremap = true, silent = true }, - { "af", ":CodeCompanion", mode = { "n", "v" }, noremap = true, silent = true }, - }, - opts = { - opts = { - language = "Japanese", - }, - adapters = { - copilot = function() - return require("codecompanion.adapters").extend("copilot", { - schema = { model = { default = "claude-sonnet-4" } }, - }) - end, - }, - display = { - diff = { - provider = "mini_diff", - }, - chat = { - auto_scroll = false, - show_header_separator = true, - -- show_settings = true, - window = { - width = 0.35, - position = "right", - }, - }, - }, - strategies = { - chat = { - adapter = "copilot", - roles = { - llm = function(adapter) - return " CodeCompanion (" .. adapter.formatted_name .. ")" - end, - user = " Me", - }, - }, - }, - extensions = { - vectorcode = { - opts = { - add_tool = true, - }, - }, - contextfiles = { - opts = { - slash_command = { - enabled = true, - name = "cursorrules", - }, - }, - }, - mcphub = { - callback = "mcphub.extensions.codecompanion", - opts = { - show_result_in_chat = true, -- Show mcp tool results in chat - make_vars = true, -- Convert resources to #variables - make_slash_commands = true, -- Add prompts as /slash commands - }, - }, + { "a", nil, desc = "AI/Claude Code" }, + { "ac", "ClaudeCode", desc = "Toggle Claude" }, + { "af", "ClaudeCodeFocus", desc = "Focus Claude" }, + { "ar", "ClaudeCode --resume", desc = "Resume Claude" }, + { "aC", "ClaudeCode --continue", desc = "Continue Claude" }, + { "am", "ClaudeCodeSelectModel", desc = "Select Claude model" }, + { "ab", "ClaudeCodeAdd %", desc = "Add current buffer" }, + { "as", "ClaudeCodeSend", mode = "v", desc = "Send to Claude" }, + { + "as", + "ClaudeCodeTreeAdd", + desc = "Add file", + ft = { "NvimTree", "neo-tree", "oil", "minifiles" }, }, + -- Diff management + { "aa", "ClaudeCodeDiffAccept", desc = "Accept diff" }, + { "ad", "ClaudeCodeDiffDeny", desc = "Deny diff" }, }, }, @@ -442,49 +440,8 @@ return { end, }, - -- EditorConfig plugin. - { "editorconfig/editorconfig-vim" }, - - -- Better '.' command. - { "tpope/vim-repeat" }, - - -- A comment-out plugin. - { "tpope/vim-commentary" }, - - -- Highlights a word under the cursor. - { "RRethy/vim-illuminate" }, - - -- Better word object handling. - { - "kylechui/nvim-surround", - version = "*", -- Use for stability; omit to use `main` branch for the latest features - config = function() - require("nvim-surround").setup() - end, - }, - -- A prettier git-diff. - { - "sindrets/diffview.nvim", - init = function() - vim.keymap.set("n", "do", ":DiffviewOpen", { silent = true }) - vim.keymap.set("n", "dr", ":DiffviewRefresh", { silent = true }) - vim.keymap.set("n", "df", ":DiffviewFileHistory %", { silent = true }) - end, - }, - - -- A Git extension. - { - "NeogitOrg/neogit", - dependencies = { "nvim-lua/plenary.nvim" }, - init = function() - vim.keymap.set("n", "dd", ":Neogit", { silent = true }) - end, - - config = function() - require("neogit").setup({}) - end, - }, + { "sindrets/diffview.nvim" }, -- An extension for Git diff and operations. -- This shows git-diff on the screen gutter area, previews hunks, deleted lines, and blames. @@ -496,37 +453,29 @@ return { on_attach = function(bufnr) local gitsigns = package.loaded.gitsigns - -- Navigation - vim.keymap.set("n", "]c", function() - if vim.wo.diff then - return "]c" - end - vim.schedule(function() - gitsigns.next_hunk() - end) - return "" - end, { expr = true, buffer = bufnr, silent = true }) + vim.keymap.set("n", "dP", gitsigns.preview_hunk, { buffer = bufnr, silent = true }) + vim.keymap.set("n", "dp", gitsigns.preview_hunk_inline, { buffer = bufnr, silent = true }) - vim.keymap.set("n", "[c", function() - if vim.wo.diff then - return "[c" - end - vim.schedule(function() - gitsigns.prev_hunk() - end) - return "" - end, { expr = true, buffer = bufnr, silent = true }) + vim.keymap.set("n", "dh", gitsigns.reset_hunk, { buffer = bufnr, silent = true }) + vim.keymap.set("v", "dh", function() + gitsigns.reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, { buffer = bufnr, silent = true }) - vim.keymap.set("n", "dp", gitsigns.preview_hunk, { buffer = bufnr, silent = true }) vim.keymap.set("n", "dt", gitsigns.toggle_deleted, { buffer = bufnr, silent = true }) + vim.keymap.set("n", "dd", gitsigns.diffthis, { buffer = bufnr, silent = true }) + vim.keymap.set("n", "dD", function() + gitsigns.diffthis("~") + end, { buffer = bufnr, silent = true }) + vim.keymap.set("n", "db", function() gitsigns.blame_line({ full = true }) end, { buffer = bufnr, silent = true }) - vim.keymap.set("n", "dq", function() + vim.keymap.set("n", "dQ", function() gitsigns.setqflist("all") end, { expr = true, buffer = bufnr, silent = true }) + vim.keymap.set("n", "dq", gitsigns.setqflist, { expr = true, buffer = bufnr, silent = true }) end, }) end,