Is there a way to make NeoVim as default text/code editor (without any bad side effects) ?
Trust me, I looked to lots of StackOverflow question/answers and tried a few things but nothing worked for me.
Note: I'm on macOS Big Sur (version 11.2.1). What I want is when I click on files to open in NeoVim.
--> For example, in ~/.zshrc (and added to ~/.bash_profile also just in case) I have:
Note: zsh is my default shell
alias nvim=$HOME/nvim-osx64/bin/nvim
export EDITOR="nvim"
export VISUAL="nvim"
When I do set
in Terminal it shows:
EDITOR=nvim
VISUAL=nvim
And yes, I quit and started the terminal (I'm using iTerm2). I even reboot.
--> I will place my $PATH here just in case it has anything to do it that. When I do echo $PATH
it shows:
--> And, just in case someone suggests:
I can't Select a File
> Open With...
and select NeoVim as default text editor, since that option doesn't show and I can't do Choose Other
since I can't select NeoVim in that way.
If anyone needs more information, please say and I will edit the question with that info. Thanks!
After a while I found the answer to my own question, here it is how you can set NeoVim in Mac as the default text editor. Now, you will be able click on files and opening them in NeoVim:
Some people recommended me to have a look at the follow links:
That didn't work for me but it served as a reference to look up related topics (automator + neovim).
After a while, I discover this blog:
Go and have a look at the blog, but here it is how you do it:
Automator
)Application
Run AppleScript
and drag that to where it says something like "Drag actions here..."Save it in the Applications folder
Get Info
or do cmd + i
, it will open informations about that file. Scroll to wher it says Open With
and select Other
. Then just go to Aplicattions folder
and select your new NeoVim "app".Note: You really need to do Right-Click
, Get Info
and look for Open With
to change in all files with that extension. If you skip Get Info
and just Right-Click + Open With, it will only work for that specific file...
This is the code from the blog:
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
This would open a new window even if you already had one open.
I change it so that it would open in a tab:
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
Note: I'm using iTerm2. If you are using another Terminal Emulator, change where it says iTerm to the name of your terminal...