Repository navigation
feat(editor): Unix entry points + platform-aware linking #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+528
−288
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7f3a484
feat(editor): add Unix entry points and platform-aware linking
f6b7826
docs(link): document the Windows retarget procedure for stale feature…
26c3427
test(link.windows): bind the run result used by the POSIX-skip assert…
618edd6
fix(vim): capability-probe the diffopt flags in shared/base.vim
944a878
test(link): cover the prefix-skip branch and harden the POSIX platfor…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| -- Thin Neovim entry point. Windows reads it from %LOCALAPPDATA%\nvim | ||
| -- (home/AppData/Local/nvim/init.lua), POSIX from ~/.config/nvim | ||
| -- (home/.config/nvim/init.lua); the two files are byte-identical on purpose | ||
| -- and source the one canonical config, home/vimfiles/nvim/init.lua, so the | ||
| -- 281-line configuration is never duplicated across operating systems. | ||
| local shared = vim.fn.expand("~/vimfiles/nvim/init.lua") | ||
| if vim.fn.filereadable(shared) == 1 then | ||
| vim.cmd.source(shared) | ||
| else | ||
| vim.notify("dotfiles: missing " .. shared .. " (run script/link)", vim.log.levels.WARN) | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| " POSIX entry point for Vim. Windows uses the install-dir entry at | ||
| " home/AppData/Local/Programs/Vim/_vimrc; both files only source shared | ||
| " configuration, nothing is configured here. | ||
| " | ||
| " vimrc_example.vim is the portable runtime template (its own header says | ||
| " "for Unix: ~/.vimrc") and it pulls in $VIMRUNTIME/defaults.vim. Sourcing it | ||
| " matters on Unix: with a user vimrc present Vim no longer auto-loads | ||
| " defaults.vim, so skipping the template would regress scrolloff/mouse/ttimeout | ||
| " that this machine has today. base.vim runs last and overrides every option it | ||
| " shares with the template, in the same order as the Windows entry. | ||
| if filereadable(expand('$VIMRUNTIME/vimrc_example.vim')) | ||
| source $VIMRUNTIME/vimrc_example.vim | ||
| endif | ||
|
|
||
| " The Windows-only `set diffexpr=MyDiff()` block is intentionally skipped: | ||
| " Vim 9 lists 'internal' in 'diffopt' on every platform (verified: | ||
| " diffopt=internal,filler,...), so MyDiff never runs on Windows either. | ||
|
|
||
| " 共通設定 (大西配列のキーマップ・背景透過を含む) | ||
| if filereadable(expand("~/vimfiles/shared/base.vim")) | ||
| source ~/vimfiles/shared/base.vim | ||
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,281 +1,11 @@ | ||
| local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" | ||
|
|
||
| if not vim.loop.fs_stat(lazypath) then | ||
| vim.fn.system({ | ||
| "git", | ||
| "clone", | ||
| "--filter=blob:none", | ||
| "https://github.com/folke/lazy.nvim.git", | ||
| "--branch=stable", | ||
| lazypath, | ||
| }) | ||
| end | ||
|
|
||
| vim.opt.rtp:prepend(lazypath) | ||
|
|
||
| -- 起動時パフォーマンス: 未使用providerを無効化 | ||
| vim.g.loaded_perl_provider = 0 | ||
| vim.g.loaded_ruby_provider = 0 | ||
| vim.g.loaded_node_provider = 0 | ||
| vim.g.loaded_python3_provider = 0 | ||
|
|
||
| vim.opt.shadafile = "NONE" | ||
| vim.opt.updatetime = 300 | ||
| vim.opt.signcolumn = "yes" | ||
| vim.opt.lazyredraw = false | ||
|
|
||
| require("lazy").setup({ | ||
| spec = { | ||
| -- 補完(blink.cmpは内部で遅延) | ||
| { | ||
| "saghen/blink.cmp", | ||
| version = "1.*", | ||
| dependencies = { | ||
| "rafamadriz/friendly-snippets", | ||
| }, | ||
| event = { "BufReadPost", "BufNewFile" }, | ||
| opts = { | ||
| -- キー設定は下で明示("preset = none"にして競合を避ける) | ||
| keymap = { | ||
| preset = "none", | ||
| ["<C-n>"] = { "select_next", "fallback" }, | ||
| ["<C-p>"] = { "select_prev", "fallback" }, | ||
| ["<C-Space>"] = { "show", "fallback" }, | ||
| ["<C-e>"] = { "hide", "fallback" }, | ||
| ["<C-d>"] = { "scroll_documentation_down", "fallback" }, | ||
| ["<C-u>"] = { "scroll_documentation_up", "fallback" }, | ||
| -- Tab / Enter / Shift-Tab は下のsmart_key()で一元処理 | ||
| }, | ||
| completion = { | ||
| documentation = { | ||
| auto_show = true, | ||
| }, | ||
| }, | ||
| sources = { | ||
| default = { | ||
| "lsp", | ||
| "path", | ||
| "snippets", | ||
| "buffer", | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| -- Git差分表示(バッファ読込時のみ) | ||
| { | ||
| "lewis6991/gitsigns.nvim", | ||
| event = { "BufReadPost", "BufNewFile" }, | ||
| opts = {}, | ||
| }, | ||
|
|
||
| -- ファイル・全文検索(コマンド起動時のみ) | ||
| { | ||
| "nvim-telescope/telescope.nvim", | ||
| cmd = "Telescope", | ||
| keys = { | ||
| { "<leader>ff", "<cmd>Telescope find_files<cr>", desc = "Find files" }, | ||
| { "<leader>fg", "<cmd>Telescope live_grep<cr>", desc = "Live grep" }, | ||
| { "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" }, | ||
| { "<leader>fh", "<cmd>Telescope help_tags<cr>", desc = "Help tags" }, | ||
| }, | ||
| dependencies = { | ||
| "nvim-lua/plenary.nvim", | ||
| }, | ||
| }, | ||
|
|
||
| -- formatter(保存時のみ) | ||
| { | ||
| "stevearc/conform.nvim", | ||
| event = { "BufWritePre" }, | ||
| cmd = { "ConformInfo" }, | ||
| opts = { | ||
| format_on_save = { | ||
| timeout_ms = 1000, | ||
| lsp_format = "fallback", | ||
| }, | ||
|
|
||
| formatters_by_ft = { | ||
| rust = { "rustfmt" }, | ||
| lua = { "stylua" }, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| -- MasonはUI用、使うときだけ起動 | ||
| { | ||
| "mason-org/mason.nvim", | ||
| cmd = { "Mason", "MasonInstall", "MasonUninstall", "MasonUpdate" }, | ||
| keys = { | ||
| { "<leader>mi", "<cmd>MasonInstall<cr>", desc = "Mason install" }, | ||
| }, | ||
| opts = {}, | ||
| }, | ||
|
|
||
| { | ||
| "neovim/nvim-lspconfig", | ||
| event = { "BufReadPost", "BufNewFile" }, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| vim.lsp.enable({ | ||
| "rust_analyzer", | ||
| "lua_ls", | ||
| }) | ||
|
|
||
| -- rust-analyzer: 型ヒント有効、リアルタイム診断有効、起動は軽量化 | ||
| vim.lsp.config("rust_analyzer", { | ||
| settings = { | ||
| ["rust-analyzer"] = { | ||
| inlayHints = { | ||
| enable = true, | ||
| parameterHints = true, | ||
| typeHints = true, | ||
| chainingHints = true, | ||
| closingBraceHints = true, | ||
| macroHints = true, | ||
| }, | ||
| check = { | ||
| workspace = false, | ||
| command = "clippy", | ||
| }, | ||
| cargo = { | ||
| allFeatures = false, | ||
| buildScripts = false, | ||
| }, | ||
| completion = { | ||
| autoimport = { enable = false }, | ||
| }, | ||
| imports = { | ||
| granularity = "Item", | ||
| group = true, | ||
| }, | ||
| diagnostics = { | ||
| enable = true, | ||
| experimental = { enable = true }, | ||
| }, | ||
| }, | ||
| }, | ||
| }) | ||
|
|
||
| -- inlay hintsトグル(\ih) | ||
| vim.keymap.set("n", "<leader>ih", function() | ||
| local ih = vim.lsp.inlay_hint or vim.lsp.buf and vim.lsp.buf.inlay_hint | ||
| -- nvim 0.10+: vim.lsp.inlay_hint.is_enabled() | ||
| if vim.lsp.inlay_hint then | ||
| if vim.lsp.inlay_hint.is_enabled({ bufnr = 0 }) then | ||
| vim.lsp.inlay_hint.disable({ bufnr = 0 }) | ||
| else | ||
| vim.lsp.inlay_hint.enable({ bufnr = 0 }) | ||
| end | ||
| end | ||
| end, { desc = "toggle inlay hints" }) | ||
|
|
||
| -- ============================================================= | ||
| -- 補完キーマップ(明示) | ||
| -- ============================================================= | ||
| -- 優先順位: | ||
| -- 1. snippet placeholder内 → vim.snippet.jump (Tab/Shift-Tab) | ||
| -- 2. blink.cmpの補完メニュー表示中 → accept / select_prev (Tab/Enter/Shift-Tab) | ||
| -- 3. それ以外 → 通常のキー入力をそのまま流す | ||
| -- | ||
| -- Tab 補完確定 / snippet次 / 通常のTab | ||
| -- Shift+Tab 補完prev / snippet前 / 通常のShift+Tab | ||
| -- Enter 補完確定 / 通常の改行 | ||
| -- C-n/p 補完候補を次/前 | ||
| -- C-Space 補完メニューを手動で開く | ||
| -- C-e 補完メニューを閉じる | ||
| -- ============================================================= | ||
|
|
||
| local function smart_key(key) | ||
| return function() | ||
| -- 1. snippet placeholderへのジャンプを優先 | ||
| if vim.snippet and vim.snippet.jumpable and vim.snippet.jumpable(1) then | ||
| vim.snippet.jump(1) | ||
| return | ||
| end | ||
| -- 2. 補完メニュー表示中ならaccept | ||
| local ok, cmp = pcall(require, "blink.cmp") | ||
| if ok and cmp.is_visible() then | ||
| cmp.accept({}) | ||
| return | ||
| end | ||
| -- 3. それ以外は通常のキー入力をそのまま流す | ||
| local keys = vim.api.nvim_replace_termcodes(key, true, false, true) | ||
| vim.api.nvim_feedkeys(keys, "n", false) | ||
| end | ||
| end | ||
|
|
||
| vim.keymap.set("i", "<Tab>", smart_key("<Tab>"), { desc = "Tab: snippet→cmp→fallback" }) | ||
| vim.keymap.set("i", "<S-Tab>", function() | ||
| if vim.snippet and vim.snippet.jumpable and vim.snippet.jumpable(-1) then | ||
| vim.snippet.jump(-1) | ||
| return | ||
| end | ||
| local ok, cmp = pcall(require, "blink.cmp") | ||
| if ok and cmp.is_visible() then | ||
| cmp.select_prev() | ||
| return | ||
| end | ||
| local keys = vim.api.nvim_replace_termcodes("<S-Tab>", true, false, true) | ||
| vim.api.nvim_feedkeys(keys, "n", false) | ||
| end, { desc = "Shift-Tab: snippet→cmp prev→fallback" }) | ||
|
|
||
| vim.keymap.set("i", "<CR>", smart_key("<CR>"), { desc = "Enter: cmp accept→fallback" }) | ||
|
|
||
| -- リアルタイム診断: virtual_text / signs を明示有効化 | ||
| vim.diagnostic.config({ | ||
| virtual_text = { | ||
| prefix = "■", | ||
| spacing = 2, | ||
| source = true, -- どのLSP由来か表示 | ||
| }, | ||
| signs = true, | ||
| severity_sort = true, | ||
| underline = true, | ||
| float = { | ||
| source = true, | ||
| border = "rounded", | ||
| }, | ||
| update_in_insert = false, -- 入力中は更新しない(重くしない) | ||
| }) | ||
|
|
||
| -- Cargo(競プロ用ターミナル開閉ヘルパー) | ||
| local function cargo_compete(cmd) | ||
| if vim.fn.executable("cargo") == 0 then | ||
| vim.notify("cargo not found", vim.log.levels.WARN) | ||
| return | ||
| end | ||
| local term_cmd = "cargo compete" .. (cmd and (" " .. cmd) or "") | ||
| vim.cmd("botright split") | ||
| vim.cmd("terminal " .. term_cmd) | ||
| local term_buf = vim.api.nvim_get_current_buf() | ||
|
|
||
| -- ターミナルが閉じられたら現在のバッファをrustfmtでフォーマット | ||
| vim.api.nvim_create_autocmd({ "BufWinLeave", "WinClosed" }, { | ||
| buffer = term_buf, | ||
| once = true, | ||
| nested = true, | ||
| callback = function() | ||
| vim.schedule(function() | ||
| local ok, conform = pcall(require, "conform") | ||
| if ok then | ||
| conform.format({ async = true, lsp_format = "fallback" }) | ||
| end | ||
| end) | ||
| end, | ||
| }) | ||
| end | ||
|
|
||
| vim.keymap.set("n", "<leader>an", function() cargo_compete("new") end, { desc = "cargo compete new" }) | ||
| vim.keymap.set("n", "<leader>ac", function() cargo_compete("") end, { desc = "cargo compete (interactive)" }) | ||
| vim.keymap.set("n", "<leader>at", function() cargo_compete("test") end, { desc = "cargo compete test" }) | ||
| vim.keymap.set("n", "<leader>as", function() cargo_compete("submit") end, { desc = "cargo compete submit" }) | ||
|
|
||
| -- 背景の透過と大西配列のキーマップは ~/vimfiles/shared/base.vim に集約している | ||
| -- (Vim 側の _vimrc と同じファイルを読み込む)。 | ||
| local shared = vim.fn.expand("~/vimfiles/shared/base.vim") | ||
| -- Thin Neovim entry point. Windows reads it from %LOCALAPPDATA%\nvim | ||
| -- (home/AppData/Local/nvim/init.lua), POSIX from ~/.config/nvim | ||
| -- (home/.config/nvim/init.lua); the two files are byte-identical on purpose | ||
| -- and source the one canonical config, home/vimfiles/nvim/init.lua, so the | ||
| -- 281-line configuration is never duplicated across operating systems. | ||
| local shared = vim.fn.expand("~/vimfiles/nvim/init.lua") | ||
| if vim.fn.filereadable(shared) == 1 then | ||
| vim.cmd.source(shared) | ||
| else | ||
| vim.notify("dotfiles: missing " .. shared .. " (run script/link)", vim.log.levels.WARN) | ||
| end |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
sed -n '40,85p' README.mdRepository: rebuildup/dotfiles
Length of output: 2235
Join the Git commands with
&&so a failedgit switch mainstops the pull and submodule update.With
;, PowerShell runsgit pullandgit submodule updateeven whengit switch mainfails.&&runs each command only after the previous one succeeds. This operator requires PowerShell 7. The plan, manual link removal, and-Applylines are separate statements, so they still run after a failed switch. Run those steps only after the Git line succeeds.script/link.ps1takes its source from the checkout that contains it and does not check the branch. Links can therefore point to a checkout that remains offmain.Suggested fix
Committable suggestion