mirror of
https://github.com/moons-14/dotfiles.git
synced 2026-10-06 08:28:11 +09:00
nixvim: improve keymaps, completion, and formatter config
- Add LSP code actions, diagnostic navigation, window navigation keymaps - Move telescope keymaps to explicit mkRaw form for reliability - Change buffer nav from <leader>bh/bl to [b/]b - Fix conform double-setup by moving config to native nixvim settings - Fix <leader>cf to use conform instead of vim.lsp.buf.format - Fix <leader>ca to pass diagnostic context to code_action - Add nvim-lightbulb for code action indicator - Configure copilot Tab conflict: blink-cmp Tab=accept, C-n/p for cycling - Add completion.list.selection preselect for immediate Tab acceptance - Add TypeScript Japanese locale for LSP diagnostics Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
This commit is contained in:
@@ -40,25 +40,5 @@
|
||||
nixd
|
||||
];
|
||||
|
||||
extraConfigLua = ''
|
||||
require("conform").setup({
|
||||
formatters_by_ft = {
|
||||
javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
javascriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescript = { "prettierd", "prettier", stop_after_first = true },
|
||||
typescriptreact = { "prettierd", "prettier", stop_after_first = true },
|
||||
json = { "prettierd", "prettier", stop_after_first = true },
|
||||
yaml = { "prettierd", "prettier", stop_after_first = true },
|
||||
markdown = { "prettierd", "prettier", stop_after_first = true },
|
||||
lua = { "stylua" },
|
||||
nix = { "alejandra" },
|
||||
sh = { "shfmt" },
|
||||
},
|
||||
format_on_save = function(_)
|
||||
return { timeout_ms = 1000, lsp_format = "fallback" }
|
||||
end,
|
||||
})
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
mode = "n";
|
||||
key = key;
|
||||
action.__raw = raw;
|
||||
|
||||
options = {
|
||||
silent = true;
|
||||
desc = desc;
|
||||
@@ -24,7 +25,13 @@ in {
|
||||
(mkRaw "gd" "vim.lsp.buf.definition" "定義へ移動")
|
||||
(mkRaw "gr" "vim.lsp.buf.references" "参照を表示")
|
||||
(mkRaw "<leader>rn" "vim.lsp.buf.rename" "シンボル名を一括変換")
|
||||
(mkRaw "<leader>cf" "vim.lsp.buf.format" "コードをフォーマット")
|
||||
(mkRaw "<leader>cf" "function() require('conform').format({ timeout_ms = 1000, lsp_format = 'fallback' }) end" "コードをフォーマット")
|
||||
(mkRaw "<leader>ca" "function() vim.lsp.buf.code_action({ context = { diagnostics = vim.diagnostic.get(0, { lnum = vim.fn.line('.') - 1 }) } }) end" "コードアクション")
|
||||
|
||||
# Diagnostics
|
||||
(mkRaw "]d" "vim.diagnostic.goto_next" "次のエラー")
|
||||
(mkRaw "[d" "vim.diagnostic.goto_prev" "前のエラー")
|
||||
(mkRaw "<leader>dl" "vim.diagnostic.open_float" "エラー詳細")
|
||||
|
||||
# File tree
|
||||
(mk "<leader>e" "<cmd>Neotree toggle left<CR>" "ファイルツリー")
|
||||
@@ -32,12 +39,24 @@ in {
|
||||
# Terminal
|
||||
(mk "<leader>tt" "<cmd>ToggleTerm direction=float<CR>" "ターミナル")
|
||||
|
||||
# Diagnostics
|
||||
# Diagnostics list
|
||||
(mk "<leader>xx" "<cmd>Trouble diagnostics toggle<CR>" "エラー一覧")
|
||||
|
||||
# Window navigation
|
||||
(mk "<C-h>" "<C-w>h" "左のウィンドウへ")
|
||||
(mk "<C-j>" "<C-w>j" "下のウィンドウへ")
|
||||
(mk "<C-k>" "<C-w>k" "上のウィンドウへ")
|
||||
(mk "<C-l>" "<C-w>l" "右のウィンドウへ")
|
||||
|
||||
# Buffer Bar
|
||||
(mk "<leader>bh" "<Cmd>BufferPrevious<CR>" "前のバッファーに移動")
|
||||
(mk "<leader>bl" "<Cmd>BufferNext<CR>" "後のバッファーに移動")
|
||||
(mk "[b" "<Cmd>BufferPrevious<CR>" "前のバッファーに移動")
|
||||
(mk "]b" "<Cmd>BufferNext<CR>" "後のバッファーに移動")
|
||||
(mk "<leader>bc" "<Cmd>BufferClose<CR>" "バッファーを削除")
|
||||
|
||||
# Telescope (explicit form for reliability)
|
||||
(mkRaw "<leader>ff" "function() require('telescope.builtin').find_files() end" "ファイルを探す")
|
||||
(mkRaw "<leader>fg" "function() require('telescope.builtin').live_grep() end" "文字列を全文検索")
|
||||
(mkRaw "<leader>fb" "function() require('telescope.builtin').buffers() end" "開いているバッファを探す")
|
||||
(mkRaw "<leader>fh" "function() require('telescope.builtin').help_tags() end" "ヘルプ項目を探す")
|
||||
];
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"jsconfig.json"
|
||||
".git"
|
||||
];
|
||||
extraOptions.settings.typescript.locale = "ja";
|
||||
};
|
||||
|
||||
# Biome for lint / format
|
||||
|
||||
@@ -12,8 +12,29 @@
|
||||
"<C-e>" = ["hide"];
|
||||
"<C-f>" = ["scroll_documentation_down"];
|
||||
|
||||
"<Tab>" = ["select_next" "fallback"];
|
||||
"<Tab>" = [
|
||||
"accept"
|
||||
{
|
||||
__raw = ''
|
||||
function()
|
||||
local ok, copilot = pcall(require, "copilot.suggestion")
|
||||
if ok and copilot.is_visible() then
|
||||
copilot.accept()
|
||||
return true
|
||||
end
|
||||
end
|
||||
'';
|
||||
}
|
||||
"fallback"
|
||||
];
|
||||
"<S-Tab>" = ["select_prev" "fallback"];
|
||||
"<C-n>" = ["select_next" "fallback"];
|
||||
"<C-p>" = ["select_prev" "fallback"];
|
||||
};
|
||||
|
||||
completion.list.selection = {
|
||||
preselect = true;
|
||||
auto_insert = false;
|
||||
};
|
||||
|
||||
sources.default = [
|
||||
|
||||
@@ -1,3 +1,24 @@
|
||||
{...}: {
|
||||
programs.nixvim.plugins."conform-nvim".enable = true;
|
||||
programs.nixvim.plugins."conform-nvim" = {
|
||||
enable = true;
|
||||
settings = {
|
||||
formatters_by_ft = {
|
||||
javascript.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
javascriptreact.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
typescript.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
typescriptreact.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
json.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
yaml.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
markdown.__raw = ''{ "prettierd", "prettier", stop_after_first = true }'';
|
||||
lua = ["stylua"];
|
||||
nix = ["alejandra"];
|
||||
sh = ["shfmt"];
|
||||
};
|
||||
format_on_save.__raw = ''
|
||||
function(_)
|
||||
return { timeout_ms = 1000, lsp_format = "fallback" }
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
{...}: {
|
||||
programs.nixvim.plugins.copilot-lua = {
|
||||
enable = true;
|
||||
settings = {
|
||||
suggestion = {
|
||||
auto_trigger = true;
|
||||
keymap.enabled = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,43 +1,6 @@
|
||||
{...}: {
|
||||
programs.nixvim = {
|
||||
plugins.telescope = {
|
||||
enable = true;
|
||||
extensions = {
|
||||
fzf-native.enable = true;
|
||||
};
|
||||
keymaps = {
|
||||
"<leader>ff" = {
|
||||
action = "find_files";
|
||||
options = {
|
||||
desc = "ファイルを探す";
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
|
||||
"<leader>fg" = {
|
||||
action = "live_grep";
|
||||
options = {
|
||||
desc = "文字列を全文検索";
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
|
||||
"<leader>fb" = {
|
||||
action = "buffers";
|
||||
options = {
|
||||
desc = "開いているバッファを探す";
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
|
||||
"<leader>fh" = {
|
||||
action = "help_tags";
|
||||
options = {
|
||||
desc = "ヘルプ項目を探す";
|
||||
silent = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
programs.nixvim.plugins.telescope = {
|
||||
enable = true;
|
||||
extensions.fzf-native.enable = true;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,5 +8,6 @@
|
||||
./toggleterm.nix
|
||||
./treesitter.nix
|
||||
./barbar.nix
|
||||
./lightbulb.nix
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{...}: {
|
||||
programs.nixvim.plugins.nvim-lightbulb = {
|
||||
enable = true;
|
||||
settings.autocmd.enabled = true;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user