Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support for VimR and neovide #1229

Closed
vlaw opened this issue Aug 4, 2021 · 30 comments
Closed

[Feature]: Support for VimR and neovide #1229

vlaw opened this issue Aug 4, 2021 · 30 comments
Labels
enhancement New feature or request

Comments

@vlaw
Copy link

vlaw commented Aug 4, 2021

Feature motivation

Since LunarVim uses a custom directory (~/.local/share/lunarvim/lvim), the LunarVim configuration cannot be loaded when opening vimr (a Neovim GUI for macOS) directly.
Even I copy it into ~/.config/nvim, it doesn't work,
because the path has been remove from packpath and runtimepath

https://github.com/ChristianChiarulli/LunarVim/blob/7cd03ff4e332e1427497b54d5ca8b037afbc0982/init.lua#L2
https://github.com/ChristianChiarulli/LunarVim/blob/7cd03ff4e332e1427497b54d5ca8b037afbc0982/init.lua#L8

PS. the command vimr --nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" works fine.

Describe the expected solution

No response

Describe the alternatives you've considered

an installation switch option to choose directory between ~/.local/share/lunarvim/lvim and ~/.config/nvim ?

Additional context

No response

@vlaw vlaw added the enhancement New feature or request label Aug 4, 2021
@sa-mendez
Copy link
Contributor

I second this. I use neovide, and would like to be able to just run with the lunarvim setup by default.

I actually ended up getting this to work by changing a few paths in a few of the files (in lunarvim 0.5.1 release), but the moment I get the next release, I know I will have to do some merges. It would be nice to have user configurable root, so that some of us that just want to use lunarvim full-time, can do so without running a different executable (lvim) and/or aliasing nvim.

@rebuilt
Copy link
Collaborator

rebuilt commented Aug 4, 2021

I actually ended up getting this to work by changing a few paths in a few of the files (in lunarvim 0.5.1 release), but the moment I get the next release, I know I will have to do some merges. It would be nice to have user configurable root, so that some of us that just want to use lunarvim full-time, can do so without running a different executable (lvim) and/or aliasing nvim.

Does this launch neovide correctly for you (without the altering of paths?)

neovide -- -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim"

@kylo252
Copy link
Collaborator

kylo252 commented Aug 4, 2021

PS. the command vimr --nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" works fine.

By the way, if that command works for you then you can add this shell function to your bashrc/zshrc

function lvimr(){
	vimr --nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" "@"
}

It would still take arguments like any typical vimr invocation. You can even have autocomplete for zsh, assuming vimr supports it, with something like this:

compdef _vimr lvimr

@vlaw
Copy link
Author

vlaw commented Aug 4, 2021

PS. the command vimr --nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" works fine.

By the way, if that command works for you then you can add this shell function to your bashrc/zshrc

function lvimr(){

	vimr --nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" "@"

}

It would still take arguments like any typical vimr invocation. You can even have autocomplete for zsh, assuming vimr supports it, with something like this:

compdef _vimr lvimr

thanks.

BUT what I mean is there are so many cases people want to open the GUI application from GUI environment, and get lunarVim loaded automatically (I guess so IMHO) 😀
And my case is, I set VimR as my default text editor, when I open a text file from Finder, VimR can't load luarvim any more😔

@sa-mendez
Copy link
Contributor

I actually ended up getting this to work by changing a few paths in a few of the files (in lunarvim 0.5.1 release), but the moment I get the next release, I know I will have to do some merges. It would be nice to have user configurable root, so that some of us that just want to use lunarvim full-time, can do so without running a different executable (lvim) and/or aliasing nvim.

Does this launch neovide correctly for you (without the altering of paths?)

neovide -- -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim"

I have not tried doing that, but if I did I would still have to alias it, or create a function (as was suggested earlier). By having the paths (really the root) be configurable, there would be no need for that. Also, it would basically have any GUI vim application (such as neovide, or VimR) just work out of the box.

I realize that this is perhaps no longer the direction that lunarvim wants to go in (though pre-0.5, it did work this way), and that I can always just grab the latest code and manually update the paths in the code myself. But it would be nice if that flexibility was re-introduced.

@vlaw vlaw changed the title [Feature]: Support for VimR [Feature]: Support for VimR and neovide Aug 5, 2021
@rebuilt
Copy link
Collaborator

rebuilt commented Aug 5, 2021

And my case is, I set VimR as my default text editor, when I open a text file from Finder, VimR can't load luarvim any morepensive

If you use the code from above. Also set your editor to lvimr. That should make finder use this alias.

@vlaw
Copy link
Author

vlaw commented Aug 5, 2021

And my case is, I set VimR as my default text editor, when I open a text file from Finder, VimR can't load luarvim any morepensive

If you use the code from above. Also set your editor to lvimr. That should make finder use this alias.

As far as I know, changing the default app needs the bundle ID of an app, not a function in shell,

$ duti -x .md
VimR
/Applications/VimR.app
com.qvacua.VimR

Can you tell me more details on how to do it? Many thanks~

@rebuilt
Copy link
Collaborator

rebuilt commented Aug 5, 2021

Can you tell me more details on how to do it? Many thanks~

Ah, sorry. I'm misleading you. That will only work from the command line, not finder.

@kylo252
Copy link
Collaborator

kylo252 commented Aug 7, 2021

I'm not sure about osx, but on Linux you can just add an entry like this one here and give it any flags you want for Exec

[Desktop Entry]
Name=LunarVim
GenericName=Text Editor
Comment=An IDE layer for Neovim with sane defaults. Completely free and community driven.
TryExec=lvim
Exec=lvim %F
Terminal=false
Type=Application
Keywords=Text;editor;
Icon=nvim
Categories=Utility;TextEditor;
StartupNotify=false
MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;text/x-c++src;text/x-chdr;text/x-csrc;text/x-java;text/x-moc;text/x-pascal;text/x-tcl;text/x-tex;application/x-shellscript;text/x-c;text/x-c++;

Another approach is to wrap that call in a shell "launcher" script, just like how lvim is run, see:

#!/bin/sh
exec nvim -u ~/.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=~/.local/share/lunarvim/lvim" "$@"

@nwaywood
Copy link
Member

I would like to request support for Goneovim as well please :) https://github.com/akiyosi/goneovim

@kylo252
Copy link
Collaborator

kylo252 commented Sep 13, 2021

This should probably work now after #1381.

Clone the repo into ~/.config/nvim and start nvim or goneovim like usual. It probably still needs some polishing, but it should hopefully work.

@nwaywood
Copy link
Member

@kylo252 wait are you saying clone the lunarvim repo into ~/.config/nvim? If it's possible I would still like to be able to have a seperate nvim config for command line and use lunarvim in the gui

@sa-mendez
Copy link
Contributor

This should probably work now after #1381.

Clone the repo into ~/.config/nvim and start nvim or goneovim like usual. It probably still needs some polishing, but it should hopefully work.

It kind of works but not without some tweaks. Some of the things like reloading the configs, and running LvimUpdate will fail

Here is what I did to get this to work:

  1. Cloned rolling into ~/.config/nvim
  2. Added the following export to my zsh (or bash) exports:

export LUNARVIM_RUNTIME_DIR=$HOME/.config/nvim

  1. This fixes the config reloading on save. In utils/init.lua, edit the function reload_lv_config() :

vim.cmd("source " .. utils.join_paths(get_runtime_dir(), "lvim", "lua", "plugins.lua"))

becomes

vim.cmd("source " .. utils.join_paths(get_runtime_dir(), "lua", "plugins.lua"))

  1. This fixes LvimUpdate command. In bootstrap.lua edit the function git_cmd(subcmd) :

local repo_dir = join_paths(get_runtime_dir(), "lvim")

becomes

local repo_dir = get_runtime_dir()

After these changes, everything works. I launch nvim, and I get lunarvim (no aliases or using lvim script). I launch neovide and it automatically uses lunarvim. Just gotta make sure that the LUNARVIM_RUNTIME_DIR variable is set.

@sa-mendez
Copy link
Contributor

sa-mendez commented Oct 2, 2021

The pattern is that in the code (and the install scripts), there is an assumption that the repository files will reside in a subdirectory of LUNARVIM_RUNTIME_DIR called lvim.

I have been looking through the code, and this can be resolved by using another environment variable (e.g. LUNARVIM_REPO_DIR) to represent this directory. After making the necessary code changes my above tweaks (minus the LUNARVIM_RUNTIME_DIR export) would simply be replaced by the following export:

export LUNARVIM_REPO_DIR=$LUNARVIM_RUNTIME_DIR

Of course, the insallers and code would default to:

$LUNARVIM_RUNTIME_DIR/lvim

I would me happy to submit a PR with the changes. My concern is that there may not be interest in pulling in my PR as this issue has been open for a while, and not had engagement in some time.

@kylo252
Copy link
Collaborator

kylo252 commented Oct 2, 2021

I have been looking through the code, and this can be resolved by using another environment variable (e.g. LUNARVIM_REPO_DIR) to represent this directory. After making the necessary code changes my above tweaks (minus the LUNARVIM_RUNTIME_DIR export) would simply be replaced by the following export:

You don't need to do that, that's the whole point 😅

My concern is that there may not be interest in pulling in my PR as this issue has been open for a while, and not had engagement in some time.

I just needed someone to test the changes, I know it works fine on Windows for example.

I would me happy to submit a PR with the changes.

Thank you! But it's a lot simpler to fix than you think. I had just forgotten to use the self.repo_dir variable, although I didn't even set it correctly. You can do something like this:

diff --git a/lua/bootstrap.lua b/lua/bootstrap.lua
index fb2099c..c6f0646 100644
--- a/lua/bootstrap.lua
+++ b/lua/bootstrap.lua
@@ -63,7 +63,6 @@ function M:init()
   self.runtime_dir = get_runtime_dir()
   self.config_dir = get_config_dir()
   self.cache_path = get_cache_dir()
-  self.repo_dir = join_paths(self.runtime_dir, "lvim")
 
   self.pack_dir = join_paths(self.runtime_dir, "site", "pack")
   self.packer_install_dir = join_paths(self.runtime_dir, "site", "pack", "packer", "start", "packer.nvim")
@@ -120,19 +119,15 @@ function M:update()
   end)
 end
 
-local function git_cmd(subcmd)
+local function git_cmd(args)
   local Job = require "plenary.job"
   local Log = require "core.log"
-  local repo_dir = join_paths(get_runtime_dir(), "lvim")
-  local args = { "-C", repo_dir }
-  vim.list_extend(args, subcmd)
 
   local stderr = {}
   local stdout, ret = Job
     :new({
       command = "git",
       args = args,
-      cwd = repo_dir,
       on_stderr = function(_, data)
         table.insert(stderr, data)
       end,
@@ -153,10 +148,16 @@ end
 ---pulls the latest changes from github
 function M:update_repo()
   local Log = require "core.log"
+
+  local repo_root = join_paths(get_runtime_dir(), "lvim")
+  if not os.getenv "LUNARVIM_RUNTIME_DIR" then
+    repo_root = vim.fn.stdpath "config"
+  end
+
   local sub_commands = {
-    fetch = { "fetch" },
-    diff = { "diff", "--quiet", "@{upstream}" },
-    merge = { "merge", "--ff-only", "--progress" },
+    fetch = { "-C", repo_root, "fetch" },
+    diff = { "-C", repo_root, "diff", "--quiet", "@{upstream}" },
+    merge = { "-C", repo_root, "merge", "--ff-only", "--progress" },

And that source command in lv-reload looks redundant, so you should delete it.

@sa-mendez
Copy link
Contributor

Thanks.

I tried to apply your diff, but I kept getting a an error about it being corrupt. So I went ahead and applied the changes manually. It looks like your line numbers did not match up with what I had from the latest pull from rolling.

Unfortunately your change did not work when I called LvimUpdate. The reason is that this code (while consistent with function _G.get_runtime_dir()):

local repo_root = join_paths(get_runtime_dir(), "lvim")
  if not os.getenv "LUNARVIM_RUNTIME_DIR" then
    repo_root = vim.fn.stdpath "config"
  end

Breaks the LvimUpdate for me. As I mentioned before, in order to get lunarvim to work, I had to define LUNARVIM_RUNTIME_DIR as:

export LUNARVIM_RUNTIME_DIR=$XDG_CONFIG_HOME/nvim

This is so that the packpath is properly setup in the bootstrap.init() method where the check for LUNARVIM_RUNTIME_DIR is performed.

The simple change would be to just update the repo_root setup to:

  if os.getenv "LUNARVIM_RUNTIME_DIR" then
    repo_root = vim.fn.stdpath "config"
  end

I tested this, and it worked. Though I am not sure if that is the right way to do this as it leads to it no longer being consistent with
function _G.get_runtime_dir().

Lastly, the function _G.get_version(type) in bootstrap is also hardcoding the lvim directory, so that should probably be changed as well.

If you think it is ok to use the corrected code above, then I can send you a diff (ill create a get_repo_dir() function since it would also be used by the get_version() function), and/or submit a PR with your changes, plus my tweaks. My only question would be if I should make the new get_repo_dir() function Global or local.

@sa-mendez
Copy link
Contributor

I noticed some additional changes were made in rolling so I have grabbed the latest. Also, now having a better understanding of how the packages are loaded and what the default directories are, I finally got everything working as I want (in both nvim and running neovide).

Here is what I changed:

  • I was wrong about needing to set LUNARVIM_RUNTIME_DIR. I have now removed this from my shell environment.

  • The code appears to still be setting the incorrect (default) run time dir in bootstrap.lua. I changed the get_runtime_dir() function as follows:

diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua
index ab29bca..8d63eda 100644
--- a/lua/lvim/bootstrap.lua
+++ b/lua/lvim/bootstrap.lua
@@ -18,7 +18,7 @@ function _G.get_runtime_dir()
   local lvim_runtime_dir = os.getenv "LUNARVIM_RUNTIME_DIR"
   if not lvim_runtime_dir then
     -- when nvim is used directly
-    return vim.fn.stdpath "config"
+    return vim.fn.stdpath "data"
   end
   return lvim_runtime_dir
 end

FYI, I am running this on Linux Manjaro.

If you agree with my change, I can submit a pull request, and I think this issue can be closed.

@kylo252
Copy link
Collaborator

kylo252 commented Oct 14, 2021

  • I was wrong about needing to set LUNARVIM_RUNTIME_DIR. I have now removed this from my shell environment.
  • The code appears to still be setting the incorrect (default) run time dir in bootstrap.lua. I changed the get_runtime_dir() function as follows:
diff --git a/lua/lvim/bootstrap.lua b/lua/lvim/bootstrap.lua
index ab29bca..8d63eda 100644
--- a/lua/lvim/bootstrap.lua
+++ b/lua/lvim/bootstrap.lua
@@ -18,7 +18,7 @@ function _G.get_runtime_dir()
   local lvim_runtime_dir = os.getenv "LUNARVIM_RUNTIME_DIR"
   if not lvim_runtime_dir then
     -- when nvim is used directly
-    return vim.fn.stdpath "config"
+    return vim.fn.stdpath "data"
   end
   return lvim_runtime_dir
 end

Yeah I've been thinking about how to resolve this, the problem is specifically related to packer's runtime, and not necessarily lvim's. I also did fix the LvimUpdate path for you in #1707.

Please do open a PR, and we can figure out the best way to solve this. We really should add some CI test for this to make sure it's not broken. I ended up removing the tests that I had attempted at the time, but it should be easier now, I hope.

@sa-mendez
Copy link
Contributor

Thanks.

Here you go:
#1777

@kylo252 kylo252 closed this as completed Nov 22, 2021
@mandarvaze
Copy link

@vlaw

PS. the command vimr --nvim -u /.local/share/lunarvim/lvim/init.lua --cmd "set runtimepath+=/.local/share/lunarvim/lvim" works fine.

I understand your above comment is almost 6 months old. Does it still "work" for you?

I do not see LunarVim Dashboard, nor do LunarVim keybindings like say SPC f f (to find file) work for me.

@sa-mendez @kylo252 Do I need to set any environment variables to get VimR to use lvim configuration ?

@kylo252
Copy link
Collaborator

kylo252 commented Feb 23, 2022

I understand your above comment is almost 6 months old. Does it still "work" for you?

I do not see LunarVim Dashboard, nor do LunarVim keybindings like say SPC f f (to find file) work for me.

@mandarvaze, this should still work. You basically need to clone this repo into ~/.config/nvim, see #1777

@mandarvaze
Copy link

@kylo252 I cloned the repo ~/.config/nvim (It is on rolling branch)
I removed my existing lvim installation
I have not set any environment variables.
Nor did I run any install script from the cloned repo.

How do I invoke vimr ?

If I start vimr from terminal without any arguments, I get a whole lot of no file errors looking for various lvim components (lvim.so etc.)

Am I missing any steps ? Am I doing something wrong ?

@kylo252
Copy link
Collaborator

kylo252 commented Feb 23, 2022

Try opening nvim first and see if you're getting any errors. You need to run :PackerSync.

@mandarvaze
Copy link

@kylo252
If I run just nvim - I still get
packer.nvim: Error running config for nvim-cmp: [string "..."]:0: attempt to index global 'lvim' (a nil value)

and :PackerSync says E492: Not an editor command: PackerSync

I think there might some caching issue somewhere. I wish I knew what it was.

@kylo252
Copy link
Collaborator

kylo252 commented Feb 24, 2022

IMPORTANT: Backup any of these folders if you need to

Please make sure to run the uninstaller.sh. Then delete all of these neovim folders manually.

rm -rf "$HOME/.config/nvim"
rm -rf "$HOME/.local/share/nvim"
rm -rf "$HOME/.cache/nvim"

Now open up nvim and check that :version is 0.6.1+ and that :checkhealth is passing correctly.

Only after you have verified that your vanilla neovim is working, do the following

git clone https://github.com/LunarVim/LunarVim ~/.config/nvim
touch ~/.config/nvim/config.lua

@mandarvaze
Copy link

@kylo252 💯
nvim checkhealth reported some error related to escape-time in tmux
So I started nvim outside tmux, after which checkhealth passed. (There were some other errors like python2 and perl not found, but those are marker optional)

I hope these instructions make it to official documentation

@riotrah
Copy link

riotrah commented Oct 1, 2022

Hi! If I do the above, and attempt to update LunarVim, I get the following (apparently unformatted) error:

"{ \"fatal: detected dubious ownership in repository at 'C:/Users/rayat/AppData/Local/nvim'\", \"'C:/Users/rayat/AppData/Local/nvim' is owned by:\", \"\\t'S-1-5-32-544'\", \"but the current user is:\", \"\\t'S-1-5-21-1947013008-3496154524-4106001452-1001'\", \"To add an exception for this directory, call:\", \"\", \"\\tgit config --global --add safe.directory C:/Users/rayat/AppData/Local/nvim\" }"

image
This makes me fear that a LunarVim update might clobber my settings. Is this unfounded? My config.lua is in the same dir as the clone, per @kylo252 's suggestion - I imagine that file is ignored and so might be safe, but wanted to make sure nonetheless

@kylo252
Copy link
Collaborator

kylo252 commented Oct 2, 2022

@riotrah, your issue is related to a recent-ish change in git, see https://github.blog/2022-04-12-git-security-vulnerability-announced

the easiest solution is back up your config and re-install lunarvim

@shepherdjerred
Copy link

IMPORTANT: Backup any of these folders if you need to

Please make sure to run the uninstaller.sh. Then delete all of these neovim folders manually.

rm -rf "$HOME/.config/nvim"
rm -rf "$HOME/.local/share/nvim"
rm -rf "$HOME/.cache/nvim"

Now open up nvim and check that :version is 0.6.1+ and that :checkhealth is passing correctly.

Only after you have verified that your vanilla neovim is working, do the following

git clone https://github.com/LunarVim/LunarVim ~/.config/nvim
touch ~/.config/nvim/config.lua

This worked perfectly after running :PackerSync!

@aasutossh
Copy link

Use this https://gitlab.com/lostneophyte/dotfiles/-/blob/main/bins/.local/bin/lvimn
lvimn

#!/usr/bin/env bash

export LUNARVIM_RUNTIME_DIR="${LUNARVIM_RUNTIME_DIR:-"$HOME/.local/share/lunarvim"}"
export LUNARVIM_CONFIG_DIR="${LUNARVIM_CONFIG_DIR:-"$HOME/.config/lvim"}"
export LUNARVIM_CACHE_DIR="${LUNARVIM_CACHE_DIR:-"$HOME/.cache/lvim"}"

export LUNARVIM_BASE_DIR="${LUNARVIM_BASE_DIR:-"$HOME/.local/share/lunarvim/lvim"}"

exec neovide -- -u "$LUNARVIM_BASE_DIR/init.lua" "$@"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

9 participants