Skip to content
Merged

CI #13

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/shellcheck-matcher.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
]
}
16 changes: 16 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 --severity=error {} +
44 changes: 21 additions & 23 deletions nvim/dein.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <expr> <Space>s '<Cmd>Deol -edit<CR>'
# '''

# --- General Rich Text Editing ---
[[plugins]]
repo = 'https://github.com/simeji/winresizer'
Expand Down Expand Up @@ -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 = '''
Expand All @@ -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]]
Expand Down
62 changes: 30 additions & 32 deletions nvim/lua/rc/lsp/keymap.lua
Original file line number Diff line number Diff line change
@@ -1,38 +1,36 @@
return function()
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set("n", "<Space>df", "<cmd>lua vim.diagnostic.open_float()<CR>", { 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", "<Space>q", "<cmd>lua vim.diagnostic.setloclist()<CR>", { noremap = true, silent = true })
vim.keymap.set("n", "<Space>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", "<Space>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", "<c-k>", 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", "<c-k>", 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", "<Space>r", vim.lsp.buf.rename, bufopts)
vim.keymap.set("n", "<Space>f", function()
require("my.utils").keep_cursor(vim.lsp.buf.format)
end, bufopts)

-- code edit
--- 関数名や変数名をリネーム
vim.keymap.set("n", "<Space>r", vim.lsp.buf.rename, bufopts)

-- workspace
--- ワークスペース一覧を表示
-- vim.keymap.set("n", "<space>wl", "<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>")
--- ワークスペースにフォルダを追加する
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder)
-- workspace
vim.keymap.set("n", "<space>wa", vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set("n", "<space>wr", vim.lsp.buf.remove_workspace_folder, bufopts)
end,
})
end
105 changes: 18 additions & 87 deletions nvim/lua/rc/treesitter.lua
Original file line number Diff line number Diff line change
@@ -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 = "<CR>",
node_incremental = "<CR>",
node_decremental = "<S-CR>",
},
},
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',
Expand All @@ -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,
})
12 changes: 12 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"minimumReleaseAge": "3 days",
"packageRules": [
{
matchDepTypes: ["action"],
excludePackagePrefixes: ["actions/"],
pinDigests: true,
},
],
}
4 changes: 3 additions & 1 deletion shlib/bash/bash-completion.sh
Original file line number Diff line number Diff line change
@@ -1,10 +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
1 change: 1 addition & 0 deletions shlib/bash/check-true-color.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
# https://blog.nakanishy.com/truecolor-vim.html
# なめらかな虹色が表示されればOK

Expand Down
2 changes: 1 addition & 1 deletion shlib/bash/fzf-wrapper.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#! /bin/sh -
#!/usr/bin/env bash

# Usage:
# fd depth base-directory
Expand Down
2 changes: 1 addition & 1 deletion shlib/bash/git-ch-id.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}")"
}
1 change: 1 addition & 0 deletions shlib/bash/pathfind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
IFS='
'
# 信頼できる場所からのみプログラムを呼び出すようにする。
# shellcheck disable=SC2034 # eval経由で参照される
OLDPATH="$PATH"
PATH=/bin:/usr/bin
export PATH
Expand Down
8 changes: 4 additions & 4 deletions shlib/bash/run-with-color.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ cyan=36
colored() {
color=$1
shift
echo -e "\033[1;${color}m$@\033[0m"
echo -e "\033[1;${color}m$*\033[0m"
}

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
Expand Down
2 changes: 2 additions & 0 deletions shlib/bash/sample.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 # 画面表示をもとに戻します。
1 change: 1 addition & 0 deletions shlib/common/git-alias.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
git config --global alias.s status
git config --global alias.d diff
git config --global alias.b branch
Expand Down
1 change: 0 additions & 1 deletion tmux-session.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ set -euo pipefail
# ───────────────────────────────
# 設定
# ───────────────────────────────
GHQ_ROOT=$(ghq root)
TMP_FILE=$(mktemp)

# ───────────────────────────────
Expand Down
Loading