🦥 nvim_get_option_value

このサイトでは以前、nvim_buf_get_optionを使用したコードを提示していたのですが、これは既にdeprecatedです。

なので必然的にnvim_get_option_valueへお乗り換えです 🚅

…まあ、そうは言っても終盤に来て説明されるまでもない事ですので、すぐ終わっちゃいます😆

:h nvim_get_option_value

nvim_get_option_value({name}, {opts})                *nvim_get_option_value()*
  Gets the value of an option. The behavior of this function matches that of
  |:set|: the local value of an option is returned if it exists; otherwise,
  the global value is returned. Local values always correspond to the
  current buffer or window, unless "buf" or "win" is set in {opts}.

  option の値を取得する。
  この関数の動作は |:set| と同じです。
  オプションが存在する場合はローカル値が返され、存在しない場合はグローバル値が返されます。
  ローカル値は、{opts} で "buf" または "win" が設定されていない限り、常に現在のバッファまたはウィンドウに対応します。

  Parameters: ~
    • {name}  Option name
    • {opts}  Optional parameters
              • scope: One of "global" or "local". Analogous to |:setglobal|
                and |:setlocal|, respectively.
              • win: |window-ID|. Used for getting window local options.
              • buf: Buffer number. Used for getting buffer local options.
                Implies {scope} is "local".
              • filetype: |filetype|. Used to get the default option for a
                specific filetype. Cannot be used with any other option.
                Note: this will trigger |ftplugin| and all |FileType|
                autocommands for the corresponding filetype.

  Return: ~
    Option value

そういえば、先日(と言っても結構前なんだけど) 新宿に降りて、西口側に行ったんです。

あの辺ってなんか絶賛再開発中🏗️ でガチャガチャしてるんですよね〜。 それを横目に階段で地上に上がろうとしたんですが…。

封鎖されている…❗ほぼ全て😑

How does it feel to be one of the beautiful people?

Now that you know who you are

崇高な人達の輪に加われた気分はどう?

君は自分が何者かを知ったんだ

What do you want to be?

And have you traveled very far?

それでどうしたいの?

君は届かない所に旅したつもり?

ここでふと思うわけです。

まあ🤭 Prison 👮‍♀️🩷

Far as the eye can see

せいぜい ここから目の届く範囲だろ

⚾ Try

簡単ではあるんですけど、やっぱ確信は欲しいので「試しに動かしてみよー。」って思うわけです。

なので、こんなコードを カ キ マ シ タ ァ❗❗

options.lua

vim.api.nvim_create_user_command('Example', function()
  local input = vim.fn.input('Option name? > ')
  local param = vim.api.nvim_get_option_value(input, {});

  vim.notify(input .. ": " .. tostring(param))
end, {})

多分こんな感じでしょう❓

早速試してみましょう❗

Quote

:Example

…ってしたら、なんか実在する適当なオプションを入力してあげてください😉

nvim_get_option_value

はい、いけました😆

How does it feel to be one of the beautiful people?

How often have you been there?

崇高な人達の輪に加わるってどんな気分?

もう頻繁に行ってるの?

Often enough to know

知れるには十分な頻度でね

What did you see when you were there?

そこでは何が見えるんだい?

Nothing that doesn’t show

見えないものなんて ないんだよ

money

さる‐まね【猿真似】

猿が、人間の動作を見て、そのとおりにまねること。

転じて、よく考えもしないで他人のまねをすることを軽蔑していう。 本質をわきまえないで、ただうわべだけをまねること。ひとまね。

🤖 copilot-cmp

これでもう自信を持って扱えますね❗あとは簡単😊

このサイトで言うと、 copilot-cmpで示した extensions/nvim-cmp-actions.luaで使ってるはずです。

extensions/nvim-cmp-actions.lua

local function has_copilot()
+  if vim.api.nvim_get_option_value('buftype', {}) == 'prompt' then
-  if vim.api.nvim_buf_get_option(0, 'buftype') == 'prompt' then
     return false
   end
   local line, col = unpack(vim.api.nvim_win_get_cursor(0))
   return col ~= 0 and vim.api.nvim_buf_get_text(0, line - 1, 0, line - 1, col, {})[1]:match '^%s*$' == nil
end

まあ、こんなもんでしょ😇

Note

ぶっちゃけ、わたしは今GitHub Copilotのサービスを切っているので動作確認が取れていません…😿

なので、変に鵜呑みにしないでください…。

内容なんて、もうほぼ無いよう🤣

Baby, you’re a rich man

Baby, you’re a rich man

ベイビー! よお リッチマン!!

ベイビー! よお リッチマン!!

zeong

Baby, you’re a rich man too

ベイビー! よお 君もリッチマンだ!!

You keep all your money in a big brown bag inside a zoo

君は全てのカネを 動物園のデカい茶封筒に詰め込んでるんだ!

gundam

What a thing to do

何を企んでるんだ!

🎺 Baby, You’re a Rich Man

How does it feel to be one of the beautiful people?

Tuned to a natural E

崇高な人達の輪に加われた気分はどう?

すっかり E に同調してるな

Happy to be that way

幸せに思うよ

なんていうかさあ…。

最近色々思うこともあるんだけど、他人の言葉を使って抗うのはわたしの弱さです。

自分でもびっくりするぐらい好き勝手やってるけど、どうか大目に見てください…😭

このサイトも、ようやく Endgame なんで❗

avengers

…理由になってねぇな🙄

Now that you’ve found another key

さて、またひとつキーを見つけたよ

Success

What are you going to play?

今度は何を奏でてくれるんだい?

🌵 Hotel California

On a dark desert highway, cool wind in my hair

Warm smell of colitas, rising up through the air

夜の砂漠のハイウェイ 髪をなでる冷たい風

コリタスの温かい香り 空気に漂い立ち上る

Up ahead in the distance, I saw a shimmering light

遠く先に かすかにきらめく光が見えた

My head grew heavy and my sight grew dim

I had to stop for the night

頭は重く 視界がぼやけてきた

どうやら ここで一夜を過ごすしかない

There she stood in the doorway

I heard the mission bell

その扉口には女性が立っている

教会の鐘の音が鳴り響く

And I was thinkin’ to myself

心の中で自分に問いかけた

"This could be Heaven or this could be Hell"

“ここは天国か あるいは地獄か”

Then she lit up a candle and she showed me the way

彼女は蝋燭を灯し 中へ案内してくれた

There were voices down the corridor

I thought I heard them say

廊下の奥からこだまする声

それはまるで こう聞こえた

Welcome to the Hotel California
Such a lovely place

なんて素敵な場所

Such a lovely face

なんて煌びやかな方々

Plenty of room at the Hotel California

当ホテルは 客室も多数揃えてございます

Any time of year

You can find it here

一年中いつでも

こちらで見つけることができますよ

Her mind is Tiffany-twisted, she got the Mercedes Benz,

She got a lot of pretty, pretty boys she calls friends

Tiffany に酔狂し, Mercedes Benz も所有する彼女には

トモダチと呼称する たくさんのかわいい、かわいいぼうやたちがいる

How they dance in the courtyard, sweet summer sweat

Some dance to remember, some dance to forget

中庭で踊るトモダチの姿, 甘い夏の汗

ある者は想い出に舞い, ある者は忘れたいが如く舞う

So I called up the Captain

ふとキャプテンに声を掛けた

"Please bring me my wine"

“ワインを持ってきてくれないか”

He said,

彼は言った

"We haven't had that spirit here since nineteen sixty nine."

“1969年以来 我々にはもう あのスピリットは無いのです.”

And still those voices are callin from far away

それでもあの声は遠い彼方からこだまする

Wake you up in the middle of the night

Just to hear them say

真夜中に俺の目を覚ましに来るんだ

ただそれを呼びかけるだけのために

Welcome to the Hotel California
Such a lovely place

なんて素敵な場所

Such a lovely face

なんて煌びやかな方々

They livin' it up at the Hotel California

皆様が 当ホテルで羽を伸ばしておられます

What a nice surprise

なんて素敵なサプライズ

Bring your alibis

アリバイは忘れず 繕ってお持ちください

Mirrors on the ceiling

The pink champagne on ice

天井には 鏡が掛かり

氷で冷やされた ピンクシャンパーニュ

and she said

彼女は言った

"We are all just prisoners here, of our own device"

“ここにいる私たちは、みんな自ら招いた運命に捕らわれた囚人なのよ”

And in the master’s chambers

They gathered for the feast

そして主の間では

彼らが 宴のために集まっていた

They stab it with their steely knives

But they just can’t kill the beast

彼らは 鉄鋼ナイフで ソレを突き刺すが

到底 野獣を殺すことなど敵わない

Last thing I remember

I was running for the door

最後の記憶では

俺は ドアに向かって走っていた

I had to find the passage back to the place I was before

かつて在った場所へ 帰る道を見つけなければならない

"Relax,"

“落ち着いて,”

said the night man

夜勤のフロントマンは言った

"We are programmed to receive

“我々は受け入れるようにプログラムされている

You can check out any time you like

But you can never leave!“

チェックアウトはいつでも好きにしていい

だが 永遠にここを脱け出すことなど叶わない!“

🦸‍♀️ WILL RETURN

What the hell is this?

これは一体どういうことだ?

friday what are they firing at?

friday、奴らは何を撃っている?

Something just entered the upper atmosphere

現在 何かが上層大気圏に突入しています