From 854482d56dfadac5601b938eb717fa78d5aae395 Mon Sep 17 00:00:00 2001 From: tomato3713 Date: Tue, 7 Apr 2026 13:55:17 +0900 Subject: [PATCH 1/4] CI --- .github/shellcheck-matcher.json | 18 ++++++++++++++++++ .github/workflows/lint.yml | 33 +++++++++++++++++++++++++++++++++ renovate.json | 13 +++++++++++++ selene.toml | 5 +++++ 4 files changed, 69 insertions(+) create mode 100644 .github/shellcheck-matcher.json create mode 100644 .github/workflows/lint.yml create mode 100644 renovate.json create mode 100644 selene.toml diff --git a/.github/shellcheck-matcher.json b/.github/shellcheck-matcher.json new file mode 100644 index 0000000..4c97a36 --- /dev/null +++ b/.github/shellcheck-matcher.json @@ -0,0 +1,18 @@ +{ + "problemMatcher": [ + { + "owner": "shellcheck", + "severity": "warning", + "pattern": [ + { + "regexp": "^(.+):(\\d+):(\\d+):\\s+(note|style|warning|error):\\s+(.+)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..1b0c7f8 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,33 @@ +name: lint + +on: + push: + branches: [main] + pull_request: + +jobs: + shellcheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - name: Run shellcheck + run: | + echo "::add-matcher::.github/shellcheck-matcher.json" + find . -name "*.sh" -exec shellcheck --format=gcc {} + + + selene: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 + - name: Install selene + env: + SELENE_VERSION: "0.30.1" + run: | + curl -sL https://github.com/Kampfkarren/selene/releases/download/${SELENE_VERSION}/selene-linux.zip -o selene.zip + unzip selene.zip + chmod +x selene + sudo mv selene /usr/local/bin/ + - name: Download Neovim type definitions + run: curl -sO https://raw.githubusercontent.com/NTBBloodbath/nvim-types/main/nvim.toml && mv nvim.toml vim.toml + - name: Run selene + run: selene nvim/ diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..db44de0 --- /dev/null +++ b/renovate.json @@ -0,0 +1,13 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended"], + "customManagers": [ + { + "customType": "regex", + "fileMatch": ["^\\.github/workflows/.*\\.yml$"], + "matchStrings": ["SELENE_VERSION: \"(?[\\d\\.]+)\""], + "depNameTemplate": "Kampfkarren/selene", + "datasourceTemplate": "github-releases" + } + ] +} diff --git a/selene.toml b/selene.toml new file mode 100644 index 0000000..15c8a01 --- /dev/null +++ b/selene.toml @@ -0,0 +1,5 @@ +name = "dotfiles" +std = "lua51+vim" + +[rules] +unused_variable = "allow" From 338627a479fb72e9d39fbce1e8754b91a9616bbf Mon Sep 17 00:00:00 2001 From: tomato3713 Date: Tue, 7 Apr 2026 14:02:08 +0900 Subject: [PATCH 2/4] update --- .github/workflows/lint.yml | 2 +- shlib/bash/bash-completion.sh | 1 + shlib/bash/check-true-color.sh | 1 + shlib/bash/run-with-color.sh | 2 +- shlib/common/git-alias.sh | 1 + 5 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 1b0c7f8..3d0ab42 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,7 +23,7 @@ jobs: env: SELENE_VERSION: "0.30.1" run: | - curl -sL https://github.com/Kampfkarren/selene/releases/download/${SELENE_VERSION}/selene-linux.zip -o selene.zip + curl -sL https://github.com/Kampfkarren/selene/releases/download/${SELENE_VERSION}/selene-${SELENE_VERSION}-linux.zip -o selene.zip unzip selene.zip chmod +x selene sudo mv selene /usr/local/bin/ diff --git a/shlib/bash/bash-completion.sh b/shlib/bash/bash-completion.sh index 00b229b..1490fa5 100644 --- a/shlib/bash/bash-completion.sh +++ b/shlib/bash/bash-completion.sh @@ -1,3 +1,4 @@ +# shellcheck shell=bash # memo command completion function _go_memo(){ local prev cur cword diff --git a/shlib/bash/check-true-color.sh b/shlib/bash/check-true-color.sh index 42e7941..b869d2e 100644 --- a/shlib/bash/check-true-color.sh +++ b/shlib/bash/check-true-color.sh @@ -1,3 +1,4 @@ +#!/bin/sh # https://blog.nakanishy.com/truecolor-vim.html # なめらかな虹色が表示されればOK diff --git a/shlib/bash/run-with-color.sh b/shlib/bash/run-with-color.sh index 0e2d29b..1e3dd18 100644 --- a/shlib/bash/run-with-color.sh +++ b/shlib/bash/run-with-color.sh @@ -19,7 +19,7 @@ cyan=36 colored() { color=$1 shift - echo -e "\033[1;${color}m$@\033[0m" + echo -e "\033[1;${color}m$*\033[0m" } run() { diff --git a/shlib/common/git-alias.sh b/shlib/common/git-alias.sh index 63d7c82..df66c96 100644 --- a/shlib/common/git-alias.sh +++ b/shlib/common/git-alias.sh @@ -1,3 +1,4 @@ +#!/bin/sh git config --global alias.s status git config --global alias.d diff git config --global alias.b branch From acd0c00ee9a9daaac3221d8067592c73df5d40ce Mon Sep 17 00:00:00 2001 From: tomato3713 Date: Tue, 7 Apr 2026 14:09:00 +0900 Subject: [PATCH 3/4] update --- .github/workflows/lint.yml | 2 +- selene.toml | 1 - shlib/bash/bash-completion.sh | 3 ++- shlib/bash/fzf-wrapper.sh | 2 +- shlib/bash/git-ch-id.sh | 2 +- shlib/bash/pathfind.sh | 1 + shlib/bash/run-with-color.sh | 6 +++--- shlib/bash/sample.sh | 2 ++ tmux-session.sh | 1 - 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 3d0ab42..082d12e 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -13,7 +13,7 @@ jobs: - name: Run shellcheck run: | echo "::add-matcher::.github/shellcheck-matcher.json" - find . -name "*.sh" -exec shellcheck --format=gcc {} + + find . -name "*.sh" -exec shellcheck --format=gcc --severity=error {} + selene: runs-on: ubuntu-latest diff --git a/selene.toml b/selene.toml index 15c8a01..fdc2139 100644 --- a/selene.toml +++ b/selene.toml @@ -1,4 +1,3 @@ -name = "dotfiles" std = "lua51+vim" [rules] diff --git a/shlib/bash/bash-completion.sh b/shlib/bash/bash-completion.sh index 1490fa5..d7ab4a4 100644 --- a/shlib/bash/bash-completion.sh +++ b/shlib/bash/bash-completion.sh @@ -1,11 +1,12 @@ # shellcheck shell=bash # memo command completion function _go_memo(){ + # shellcheck disable=SC2034 # _get_comp_words_by_ref が参照渡しで設定する local prev cur cword # get the input informations (ref: /usr/share/bash-completion/bash_completion ) _get_comp_words_by_ref -n : cur prev cword opts="new list edit cat delete grep config serve" - COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + mapfile -t COMPREPLY < <(compgen -W "${opts}" -- "${cur}") } && complete -F _go_memo memo diff --git a/shlib/bash/fzf-wrapper.sh b/shlib/bash/fzf-wrapper.sh index c14de5c..ca21823 100644 --- a/shlib/bash/fzf-wrapper.sh +++ b/shlib/bash/fzf-wrapper.sh @@ -1,4 +1,4 @@ -#! /bin/sh - +#!/usr/bin/env bash # Usage: # fd depth base-directory diff --git a/shlib/bash/git-ch-id.sh b/shlib/bash/git-ch-id.sh index 85b9332..7903033 100644 --- a/shlib/bash/git-ch-id.sh +++ b/shlib/bash/git-ch-id.sh @@ -8,5 +8,5 @@ ch-git-name() opt="s/${oldID}/${newID}/" - git remote set-url origin `git config --get remote.origin.url | sed "${opt}"` + git remote set-url origin "$(git config --get remote.origin.url | sed "${opt}")" } diff --git a/shlib/bash/pathfind.sh b/shlib/bash/pathfind.sh index cc6d4fe..9b53ba1 100644 --- a/shlib/bash/pathfind.sh +++ b/shlib/bash/pathfind.sh @@ -22,6 +22,7 @@ IFS=' ' # 信頼できる場所からのみプログラムを呼び出すようにする。 +# shellcheck disable=SC2034 # eval経由で参照される OLDPATH="$PATH" PATH=/bin:/usr/bin export PATH diff --git a/shlib/bash/run-with-color.sh b/shlib/bash/run-with-color.sh index 1e3dd18..0b5a1b4 100644 --- a/shlib/bash/run-with-color.sh +++ b/shlib/bash/run-with-color.sh @@ -27,9 +27,9 @@ run() { result=$? if [ $result -ne 0 ]; then - echo -n $(colored $red "Faild: ") - echo -n $(colored $cyan "$0") - echo $(colored $yellow " [$PWD]") + echo -n "$(colored $red "Faild: ")" + echo -n "$(colored $cyan "$0")" + echo "$(colored $yellow " [$PWD]")" exit $result fi return 0 diff --git a/shlib/bash/sample.sh b/shlib/bash/sample.sh index cdc924e..bb26187 100644 --- a/shlib/bash/sample.sh +++ b/shlib/bash/sample.sh @@ -11,7 +11,9 @@ fi # passwordの入力等で必ず人出で入力してほしいデータを読み込む場合などに便利なファイル printf "New Password" stty -echo # 入力された文字が表示されるのを防ぐ +# shellcheck disable=SC2034 read pass < /dev/tty # パスワードを読み込みます printf "Confirm Password" +# shellcheck disable=SC2034 read pass2 < /dev/tty # もう一度パスワードを読み込みます stty echo # 画面表示をもとに戻します。 diff --git a/tmux-session.sh b/tmux-session.sh index 5a5d83f..d4ae3f9 100755 --- a/tmux-session.sh +++ b/tmux-session.sh @@ -4,7 +4,6 @@ set -euo pipefail # ─────────────────────────────── # 設定 # ─────────────────────────────── -GHQ_ROOT=$(ghq root) TMP_FILE=$(mktemp) # ─────────────────────────────── From 6321f18afcc201c3151fa33e9fc3e370fa7e4189 Mon Sep 17 00:00:00 2001 From: tomato3713 Date: Tue, 21 Apr 2026 11:06:58 +0900 Subject: [PATCH 4/4] update --- .github/workflows/lint.yml | 17 ------ nvim/dein.toml | 44 ++++++++-------- nvim/lua/rc/lsp/keymap.lua | 62 +++++++++++----------- nvim/lua/rc/treesitter.lua | 105 +++++++------------------------------ renovate.json | 15 +++--- selene.toml | 4 -- 6 files changed, 76 insertions(+), 171 deletions(-) delete mode 100644 selene.toml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 082d12e..23116ec 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,20 +14,3 @@ jobs: run: | echo "::add-matcher::.github/shellcheck-matcher.json" find . -name "*.sh" -exec shellcheck --format=gcc --severity=error {} + - - selene: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - - name: Install selene - env: - SELENE_VERSION: "0.30.1" - run: | - curl -sL https://github.com/Kampfkarren/selene/releases/download/${SELENE_VERSION}/selene-${SELENE_VERSION}-linux.zip -o selene.zip - unzip selene.zip - chmod +x selene - sudo mv selene /usr/local/bin/ - - name: Download Neovim type definitions - run: curl -sO https://raw.githubusercontent.com/NTBBloodbath/nvim-types/main/nvim.toml && mv nvim.toml vim.toml - - name: Run selene - run: selene nvim/ diff --git a/nvim/dein.toml b/nvim/dein.toml index 2d13fde..d6d8798 100644 --- a/nvim/dein.toml +++ b/nvim/dein.toml @@ -100,28 +100,6 @@ lua_source = ''' require('rc.hlchunk') ''' -[[plugins]] -repo = 'https://github.com/MeanderingProgrammer/render-markdown.nvim' -depends = [ 'nvim-treesitter' ] -on_ft = [ 'markdown', "markdown.mdx", "codecompanion" ] -lua_source = ''' -require('render-markdown').setup({ - file_types = { "markdown", "Avante", "codecompanion" }, -}) -''' - -# [[plugins]] -# repo = 'Shougo/deol.nvim' -# hook_source = ''' -# " Should set g:deol#prompt_pattern. -# let g:deol#prompt_pattern = has('win32') ? '\f\+>' : '\w*% \?' -# if !has('win32') -# let g:deol#external_history_path = '~/.zsh_history' -# endif -# -# nnoremap s 'Deol -edit' -# ''' - # --- General Rich Text Editing --- [[plugins]] repo = 'https://github.com/simeji/winresizer' @@ -305,7 +283,7 @@ require('nvim-ts-autotag').setup() [[plugins]] repo = 'https://github.com/nvim-treesitter/nvim-treesitter' -on_event = ['BufRead', 'CursorHold'] +rev = 'main' merged = 0 hook_post_update = 'TSUpdate' lua_source = ''' @@ -314,7 +292,27 @@ require('rc.treesitter') [[plugins]] repo = 'https://github.com/nvim-treesitter/nvim-treesitter-textobjects' +rev = 'main' depends = ['nvim-treesitter'] +lua_source = ''' +require("nvim-treesitter-textobjects").setup({ select = { lookahead = true } }) +local select = require("nvim-treesitter-textobjects.select") +local keymaps = { + ab = { "@block.outer", "Select outer part of a block region" }, + ib = { "@block.inner", "Select inner part of a block region" }, + ai = { "@conditional.outer", "Select outer part of a conditional" }, + ii = { "@conditional.inner", "Select inner part of a conditional" }, + al = { "@loop.outer", "Select outer part of a loop" }, + il = { "@loop.inner", "Select inner part of a loop" }, + af = { "@function.outer", "Select outer part of a method/function definition" }, + ["if"] = { "@function.inner", "Select inner part of a method/function definition" }, +} +for key, v in pairs(keymaps) do + vim.keymap.set({ "x", "o" }, key, function() + select.select_textobject(v[1], "textobjects") + end, { desc = v[2] }) +end +''' # --- Git --- [[plugins]] diff --git a/nvim/lua/rc/lsp/keymap.lua b/nvim/lua/rc/lsp/keymap.lua index 0a51dde..4c3f666 100644 --- a/nvim/lua/rc/lsp/keymap.lua +++ b/nvim/lua/rc/lsp/keymap.lua @@ -1,38 +1,36 @@ return function() --- See `:help vim.diagnostic.*` for documentation on any of the below functions -vim.keymap.set("n", "df", "lua vim.diagnostic.open_float()", { noremap = true, silent = true }) -vim.keymap.set("n", "[e", function() vim.diagnostic.jump({ count = -1 }) end, { noremap = true, silent = true }) -vim.keymap.set("n", "]e", function() vim.diagnostic.jump({ count = 1 }) end, { noremap = true, silent = true }) -vim.keymap.set("n", "q", "lua vim.diagnostic.setloclist()", { noremap = true, silent = true }) -vim.keymap.set("n", "f", - function() require("my.utils").keep_cursor(vim.lsp.buf.format) end, - { noremap = true, silent = true }) + -- diagnostics (LSP 不要なのでグローバル設定) + local opts = { noremap = true, silent = true } + vim.keymap.set("n", "gs", vim.diagnostic.open_float, opts) + vim.keymap.set("n", "[e", function() + vim.diagnostic.jump({ count = -1 }) + end, opts) + vim.keymap.set("n", "]e", function() + vim.diagnostic.jump({ count = 1 }) + end, opts) + vim.keymap.set("n", "q", vim.diagnostic.setloclist, opts) + -- LSP keymaps (LspAttach でバッファローカルに設定) + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local bufopts = { noremap = true, silent = true, buffer = args.buf } - local bufopts = { noremap = true, silent = true, buffer = bufnr } - -- code reading - -- show information at cursor - --- 定義情報などを表示する - vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) - --- 関数の引数の内容とかを表示する - vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) - --- カーソル行のエラーを表示 - vim.keymap.set("n", "gs", vim.diagnostic.open_float, bufopts) + -- code reading + --- 定義情報などを表示する + vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts) + --- 関数の引数の内容とかを表示する + vim.keymap.set("n", "", vim.lsp.buf.signature_help, bufopts) - -- code walking - --- 前のエラーに移動 - vim.keymap.set("n", "g[", function() vim.diagnostic.jump({ count = -1 }) end, bufopts) - --- 次のエラーに移動 - vim.keymap.set("n", "g]", function() vim.diagnostic.jump({ count = 1 }) end, bufopts) + -- code edit + --- 関数名や変数名をリネーム + vim.keymap.set("n", "r", vim.lsp.buf.rename, bufopts) + vim.keymap.set("n", "f", function() + require("my.utils").keep_cursor(vim.lsp.buf.format) + end, bufopts) - -- code edit - --- 関数名や変数名をリネーム - vim.keymap.set("n", "r", vim.lsp.buf.rename, bufopts) - - -- workspace - --- ワークスペース一覧を表示 - -- vim.keymap.set("n", "wl", "lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))") - --- ワークスペースにフォルダを追加する - vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder) - vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder) + -- workspace + vim.keymap.set("n", "wa", vim.lsp.buf.add_workspace_folder, bufopts) + vim.keymap.set("n", "wr", vim.lsp.buf.remove_workspace_folder, bufopts) + end, + }) end diff --git a/nvim/lua/rc/treesitter.lua b/nvim/lua/rc/treesitter.lua index 11d5294..3c2d189 100644 --- a/nvim/lua/rc/treesitter.lua +++ b/nvim/lua/rc/treesitter.lua @@ -1,91 +1,22 @@ -require 'nvim-treesitter.configs'.setup { - ensure_installed = { - "go", - "gotmpl", - "tsx", "css", - "lua", - "perl", - "markdown", "toml", "yaml", "json", - }, - auto_install = false, - sync_install = false, -- install languages synchronously (only applied to `ensure_installed`) - highlight = { - enable = true, -- false will disable the whole extension - disable = { "vim" }, -- list of language that will be disabled - additional_vim_regex_highlighting = false, - }, - indent = { - enable = true, - }, - context_commentstring = { - enable_autocmd = false, - }, - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - node_decremental = "", - }, - }, - textobjects = { - select = { - enable = true, - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - keymaps = { - ["ab"] = { - query = "@block.outer", - desc = "Select outer part of a block region" - }, - ["ib"] = { - query = "@block.inner", - desc = "Select inner part of a block region" - }, - - ["ai"] = { - query = "@conditional.outer", - desc = "Select outer part of a conditional" - }, - ["ii"] = { - query = "@conditional.inner", - desc = "Select inner part of a conditional" - }, - - ["al"] = { - query = "@loop.outer", - desc = "Select outer part of a loop" - }, - ["il"] = { - query = "@loop.inner", - desc = "Select inner part of a loop" - }, +-- Parser installation (new API; replaces ensure_installed) +local installed = require('nvim-treesitter.config').get_installed() +local parsers = { "go", "gotmpl", "tsx", "css", "lua", "perl", "markdown", "toml", "yaml", "json" } +local to_install = vim.iter(parsers) + :filter(function(p) return not vim.tbl_contains(installed, p) end) + :totable() +if #to_install > 0 then + require('nvim-treesitter').install(to_install) +end - ["af"] = { - query = "@function.outer", - desc = "Select outer part of a method/function definition", - }, - ["if"] = { - query = "@function.inner", - desc = "Select inner part of a method/function definition", - }, - - }, - }, - }, -} - --- go template engine --- local parser_config = require 'nvim-treesitter.parsers'.get_parser_configs() --- parser_config.gotmpl = { --- install_info = { --- url = "https://github.com/ngalaiko/tree-sitter-go-template", --- files = { "src/parser.c" } --- }, --- filetype = "gotmpl", --- used_by = { "gohtmltmpl", "gotexttmpl", "gotmpl", "yaml" } --- } +-- Highlighting and indentation via Neovim built-in treesitter (0.12+) +vim.api.nvim_create_autocmd('FileType', { + callback = function() + pcall(vim.treesitter.start) + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, +}) +-- Filetype detection vim.filetype.add({ extension = { gotmpl = 'gotmpl', @@ -100,6 +31,6 @@ vim.filetype.add({ vim.api.nvim_create_autocmd({ "BufNewFile", "BufRead" }, { pattern = { "*.tmpl" }, callback = function() - vim.bo.filetype = "gotmpl" + vim.bo.filetype = "gotmpl" end, }) diff --git a/renovate.json b/renovate.json index db44de0..e71b655 100644 --- a/renovate.json +++ b/renovate.json @@ -1,13 +1,12 @@ { "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": ["config:recommended"], - "customManagers": [ + "minimumReleaseAge": "3 days", + "packageRules": [ { - "customType": "regex", - "fileMatch": ["^\\.github/workflows/.*\\.yml$"], - "matchStrings": ["SELENE_VERSION: \"(?[\\d\\.]+)\""], - "depNameTemplate": "Kampfkarren/selene", - "datasourceTemplate": "github-releases" - } - ] + matchDepTypes: ["action"], + excludePackagePrefixes: ["actions/"], + pinDigests: true, + }, + ], } diff --git a/selene.toml b/selene.toml deleted file mode 100644 index fdc2139..0000000 --- a/selene.toml +++ /dev/null @@ -1,4 +0,0 @@ -std = "lua51+vim" - -[rules] -unused_variable = "allow"