0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

20240331 日記、Neovim、RushRoyaleのリソース調査、Edgeのグーグルアカウント、Powershell

Posted at

Neovim

checkhealthの警告を潰していく

nvim-treesitter のこれ

nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v21.6.2 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `gcc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: gcc (x86_64-posix-seh-rev1, Built by MinGW-Builds project) 13.2.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

とNode.jsのこれ

Node.js provider (optional) ~
- Node.js: v21.6.2
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim
tree-sitterの方
  • gcc.exeが入ってない場合、scoop install mingwでいれる
  • tree-sitterもscoopでいれる。scoop install tree-sitter
node.jsの方
  • nodejsが入ってない場合scoop install nodejsで入れる
  • neovimというnode.jsパッケージが必要なのでnpm install neovimで入れる

入った後の表示

tree-sitterはこうなる

Installation ~
- OK `tree-sitter` found 0.22.2 (fc15f621334a262039ffaded5937e2844f88da61) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v21.7.1 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `gcc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: gcc (x86_64-posix-seh-rev1, Built by MinGW-Builds project) 13.2.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

nodejeはこう

Node.js provider (optional) ~
- Node.js: v21.7.1
- Nvim node.js host: D:\Users\(名前)\scoop\persist\nodejs\bin\node_modules/neovim/bin/cli.js
- OK Latest "neovim" npm/yarn/pnpm package is installed: 5.1.0

Pythonデバッグ環境つくる

いままでずっとpdb.set_traceで止めてきたけどもういい加減うんざりだ
でもまた今度にしよう

RRのリソースファイルを読みこむツール

PCに入れるとここに入ってるやつら、文字列があれこれ入っている

image.png

※ 今右側のパネルで開いているのはLocalizationDataEnglish.binというファイル

バイナリなのでYAMLにする
json?嫌いやねん

ファイルのフォーマットについて

仮説
  1. キーワードの文字列長+0x80
  2. キーワード(ASCII)
  3. 00とか区切り文字(次の文字列が長いときはちょっと複雑)
  4. キーワード本文の文字列長+0x80
  5. 文字列

という感じで並んでいるように思える

あまり難しくなさそう
これなんてフォーマットなんだろう?MsgPackというのに似てるけど
参考: MessagePack: It's like JSON. but fast and small.

例1、簡単なの

たとえば、最初のところだと

ascii
�in_event_desc□�Event
hex
8D 69 6E 5F 65 76 65 6E 74 5F 64 65 73 63 00 85
45 76 65 6E 74

となっている

  1. 0x8Dから0x80を引いて0xD=13文字
  2. キーワードは13文字、in_event_desc
  3. で次に00が区切り文字
  4. 0x85から0x80を引いて0x5=5文字
  5. 文字列は5文字、Event

仮説通りだ

例2、長いの

めちゃくちゃ文字列が長いやつだと、4番目が1バイト(最大FF、80引くと127文字)に収まらないので、ちょっと変わってくる
つまり仮説通りではない

たとえば、342文字の場合だと

ascii(本当は改行されてない)
�spring_mod_BasketWithFlowers_desc□□V□A Magic Flower 
appears near the field. You can move a unit onto it to 
exchange it for a Blossom after <color=#2b83e7>{0}s</color>.
hex
A1 73 70 72 69 6E 67 5F 6D 6F 64 5F 42 61 73 6B
65 74 57 69 74 68 46 6C 6F 77 65 72 73 5F 64 65
73 63 01 02 56 01 41 20 4D 61 67 69 63 20 46 6C
6F 77 65 72 20 61 70 70 65 61 72 73 20 6E 65 61
72 20 74 68 65 20 66 69 65 6C 64 2E 20 59 6F 75
20 63 61 6E 20 6D 6F 76 65 20 61 20 75 6E 69 74
20 6F 6E 74 6F 20 69 74 20 74 6F 20 65 78 63 68
61 6E 67 65 20 69 74 20 66 6F 72 20 61 20 42 6C
6F 73 73 6F 6D 20 61 66 74 65 72 20 3C 63 6F 6C
6F 72 3D 23 32 62 38 33 65 37 3E 7B 30 7D 73 3C
2F 63 6F 6C 6F 72 3E 2E
キーワード

キーワードは127文字を超えるものがない、と思うのでたぶん問題ない
今まで通りである

  1. 0xA1-0x80=0x21、DECだと33文字
  2. キーワードのspring_mod_BasketWithFlowers_descの長さと一致する

しかしその後の区切り文字が00でない

区切り文字と文字列長

35バイト目の01から区切り文字、00ではなく01になっている
文字列長まで含めると01 02 56 01
文字列の長さはA Magic Flower appears near the field. You can move a unit onto it to exchange it for a Blossom after <color=#2b83e7>{0}s</color>.なので、342文字、HEXにして0x80足すと0x156で3~4バイトの56 01と合致する
もっと長い文章があれば確実なんだろうけど、おそらくここは単純に逆順に格納している
リトルエンディアンとかそんなやつだと思う、よくわからないけど

ここからは仮説だけど、01 0202は文字列長のバイト数を示していると思う
そして01は文字列長のバイト数を示す02のバイト数を示しているのでは、と思う
区切り文字が00のときは、何バイトが文字列長に使われるか考える必要なく、直後の1バイトを文字列長として扱う
01~0nなどのときは直後の1~nバイトを読んで、何バイトが文字列長の長さを示すバイト数に使われるのか、判別している、んだろうと思う

最終的なフォーマット(おそらくこれが正しい)
  1. キーワードの文字列長+0x80
  2. キーワード(ASCII)
  3. キーワード本文の文字列長を示すバイト部分
    • 127文字までは00
    • それを超える場合、65407文字までは01 02
  4. キーワード本文の文字列長+0x80
    • 127文字以上になる場合は2バイト使って表す。さらにリトルエンディアン方式で格納される
  5. 文字列

キーワードはたぶん127文字を超えるものがないんだろう、、、たぶん
いまのところ、enchantment_common_fightingexcitement_short_descriptionの55文字が最長

とりあえず今日はここまで

MS Edgeのグーグルアカウント、関連付けについて

起動するたびにいつも別のアカウントになっていて、都度ログインしなおしをしていた
めんどいなあとおもって調べると以下の手順でデフォルトアカウントを変更できるらしい

  1. いったんGoogleアカウントアイコンをクリックして、メニューの「すべてのアカウントからログアウト」を行う(下図)
  2. 望みのアカウントでログインしなおす
    image.png

やってみたら治った、感謝!
参考: PCでブラウザ(Microsoft Edge)のデフォルトアカウントの変更の仕方を教えてほしいです - Google アカウント コミュニティ

PowerShell改善

gowやめてuutils-coreutilsを使う

Rust製だそうだ、ステキ
scoop install uutils-coreutils-leanで入れるけど、そのままだとcoreutils lsとめんどいのでちょっといい感じにする

$profileに以下を追加
@"
  arch, base32, base64, basename, cat, cksum, comm, cp, cut, date, df, dircolors, dirname,
  echo, env, expand, expr, factor, false, fmt, fold, hashsum, head, hostname, join, link, ln, ls,
  md5sum, mkdir, mktemp, more, mv, nl, nproc, od, paste, printenv, printf, ptx, pwd,
  readlink, realpath, relpath, rm, rmdir, seq, sha1sum, sha224sum, sha256sum, sha3-224sum,
  sha3-256sum, sha3-384sum, sha3-512sum, sha384sum, sha3sum, sha512sum, shake128sum,
  shake256sum, shred, shuf, sleep, sort, split, sum, sync, tac, tail, tee, test, touch, tr,
  true, truncate, tsort, unexpand, uniq, wc, whoami, yes
"@ -split ',' |
ForEach-Object { $_.trim() } |
Where-Object { ! @('tee', 'sort', 'sleep').Contains($_) } |
ForEach-Object {
    $cmd = $_
    if (Test-Path Alias:$cmd) { Remove-Item -Path Alias:$cmd }
    $fn = '$input | uutils ' + $cmd + ' $args'
    Invoke-Expression "function global:$cmd { $fn }" 
}

参考:【0からのWindows環境構築】Powershellの操作をできるだけLinux/Macの操作感に近づける (Linuxコマンド導入+α)

ただし、いろいろ重要ツールがたりない

途中で見つけたこのサイト便利すぎる
Rewritten in Rust: Modern Alternatives of Command-Line Tools · Zaiste Programming

coreutilsでもfzfでコマンド履歴

gowのツール群つかっていちおう対応していた

$profile、fzfとgowのawkでコマンド履歴を見るようにしていたやつ
# Fzf + Ctrl-r
Set-PSReadLineKeyHandler -Chord Ctrl+r -ScriptBlock {
  Get-Content (Get-PSReadLineOption).HistorySavePath > $ENV:USERPROFILE/tmp/ctrlr 
  $command = tac $ENV:USERPROFILE/tmp/ctrlr | awk '!a[$0]++' | fzf -e +s
  Remove-Item $ENV:USERPROFILE/tmp/ctrlr
  [Microsoft.PowerShell.PSConsoleReadLine]::InvokePrompt()
  if (!$command) { return } 
  [Microsoft.PowerShell.PSConsoleReadLine]::Insert($command)
}

が、awkがないのでエラーになる、そこでInstall-Module -Name PSFzfして、$profileを変更した

$profile、修正版、PSFzfを利用
# Fzf + Ctrl-r
Set-PsFzfOption -PSReadlineChordReverseHistory 'Ctrl+r'

え、超らくちん...

参考:【macOS で PowerShell Core】PSFzf でコマンド履歴を曖昧検索する | DevelopersIO

posh-git

こないだも書いた気がするけどposh-git
zoxideとか別にpromptを定義しているとやってくれないので事前に宣言されているなら削除するようにした

$profile
try {
  (get-command -Name 'prompt' -ErrorAction Stop) | out-null
  Remove-Item function:prompt
}
catch {
  # Nothing to do
}
Import-Module posh-git
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?