有没有办法让 NeoVim 作为默认的文本/代码编辑器(没有任何不良的副作用)?
相信我,我查看了很多 StackOverflow 问题/答案并尝试了一些方法,但没有任何效果。
注意:我使用的是macOS Big Sur(版本11.2.1)。我想要的是当我点击要在 NeoVim 中打开的文件时。
-->例如,在~/.zshrc中(并添加到 ~/.bash_profile 以防万一)我有:
注意:zsh 是我的默认 shell
alias nvim=$HOME/nvim-osx64/bin/nvim
export EDITOR="nvim"
export VISUAL="nvim"
Run Code Online (Sandbox Code Playgroud)
当我set
在终端中执行时,它显示:
EDITOR=nvim
VISUAL=nvim
Run Code Online (Sandbox Code Playgroud)
是的,我退出并启动了终端(我正在使用iTerm2)。我什至重新启动。
--> 我将把我的 $PATH放在这里,以防万一它有任何事情要做。当我这样做时,echo $PATH
它显示:
--> 而且,以防万一有人建议:
我不能Select a File
>Open With...
并选择 NeoVim 作为默认文本编辑器,因为该选项不会显示,而且我也不能这样做,Choose Other
因为我无法以这种方式选择 NeoVim。
如果有人需要更多信息,请说出来,我将使用该信息编辑问题。谢谢!
一段时间后,我找到了自己问题的答案,这里是如何将 Mac 中的 NeoVim 设置为默认文本编辑器。现在,您将能够单击文件并在 NeoVim 中打开它们:
有些人建议我查看以下链接:
这对我来说不起作用,但它可以作为查找相关主题(automator + neovim)的参考。
过了一段时间,我发现了这个博客:
去看看博客,但你可以这样做:
Automator
)Application
Run AppleScript
并将其拖动到显示“将操作拖动到此处...”之类的位置Save it in the Applications folder
Get Info
或执行cmd + i
,它将打开有关该文件的信息。滚动到显示的位置Open With
并选择Other
。然后只需转到Aplicattions folder
并选择您的新 NeoVim“应用程序”。注意:您确实需要执行Right-Click
,Get Info
并在具有该扩展名的所有文件中查找Open With
更改。如果您跳过Get Info
并仅右键单击+打开方式,它将仅适用于该特定文件...
这是博客中的代码:
on run {input, parameters}
set cmd to "nvim"
if input is not {} then
set filePath to POSIX path of input
set cmd to "nvim \"" & filePath & "\""
end if
tell application "iTerm"
create window with default profile
tell the current window
tell the current session to write text cmd
end tell
end tell
end run
Run Code Online (Sandbox Code Playgroud)
即使您已经打开了一个窗口,这也会打开一个新窗口。
我对其进行了更改,以便它可以在选项卡中打开:
on run {input, parameters}
set cmd to "nvim"
if input is not {} then
set filePath to POSIX path of input
set cmd to "nvim \"" & filePath & "\""
end if
tell application "iTerm"
tell the current window
create tab with default profile
tell the current session to write text cmd
end tell
end tell
end run
Run Code Online (Sandbox Code Playgroud)
注意:我使用的是 iTerm2。如果您使用的是另一个终端模拟器,请将 iTerm 更改为您的终端名称...
归档时间: |
|
查看次数: |
12582 次 |
最近记录: |