SuperBo / fugit2.nvim

Neovim git GUI powered by libgit2
MIT License
326 stars 7 forks source link

Installation experience / doc improvement suggestions #77

Closed Anrock closed 1 day ago

Anrock commented 1 week ago

Did you check the docs?

Is your feature request related to a problem? Please describe.

I'm using neovim 0.11.0 and Rocks.

I've checked installation section in README and made sure I have libgit2 installed via my package manager.

I've checked corresponding Rocks section which told me I don't need anything else except just installing the plugin.

I've executed :Rocks install fugit2.nvim and plugin was succesfully installed

I've restarted my neovim and executed :Fugit2 (I was already in git repo), got an error:

Error executing Lua callback: ...in/.local/share/nvim/rocks/rocks_rtp/lua/fugit2/git2.lua:1972: attempt to index field 'C' (a nil value)
stack traceback:
        ...in/.local/share/nvim/rocks/rocks_rtp/lua/fugit2/git2.lua:1972: in function 'open'
        ...in/.local/share/nvim/rocks/rocks_rtp/lua/fugit2/init.lua:68: in function 'open_repository'
        ...in/.local/share/nvim/rocks/rocks_rtp/lua/fugit2/init.lua:87: in function <...in/.local/share/nvim/rocks/rocks_rtp/lua/fugit2/init.lua:86>

I've rechecked the README file and found there is separate installation guide. First part was copypasted from README for some reason but there was a section about libgit2.

Apparently I have to set libgit2 path in plugin config. All examples for setting libgit2 are given using some specific package manager I don't use.

I've checked plugin source code to see how it's configured. The usual require(...).setup({...}) it seems. I've added setup call to my config, restarted neovim and tried executing :Fugit2 and now I got:

Error executing Lua callback: .../rocks_rtp/lua/fugit2/view/components/file_tree_view.lua:9: module 'nvim-web-devicons' not found:Failed loading module nvim-web-devicons in LuaRocks rock nvim
-web-devicons 0.99-1
        no field package.preload['nvim-web-devicons']
        no file './nvim-web-devicons.lua'
        no file '/usr/share/luajit-2.1/nvim-web-devicons.lua'
        no file '/usr/local/share/lua/5.1/nvim-web-devicons.lua'
        no file '/usr/local/share/lua/5.1/nvim-web-devicons/init.lua'
        no file '/usr/share/lua/5.1/nvim-web-devicons.lua'
        no file '/usr/share/lua/5.1/nvim-web-devicons/init.lua'
        no file '/home/shtepin/.local/share/nvim/rocks/share/lua/5.1/nvim-web-devicons.lua'
        no file '/home/shtepin/.local/share/nvim/rocks/share/lua/5.1/nvim-web-devicons/init.lua'
        no file '/usr/share/lua/5.1/init.lua'
        no file './nvim-web-devicons.so'
        no file '/usr/local/lib/lua/5.1/nvim-web-devicons.so'
        no file '/usr/lib64/lua/5.1/nvim-web-devicons.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/home/shtepin/.local/share/nvim/rocks/lib/lua/5.1/nvim-web-devicons.so'
        no file '/home/shtepin/.local/share/nvim/rocks/lib64/lua/5.1/nvim-web-devicons.so'
stack traceback:
        [C]: in function 'require'
        .../rocks_rtp/lua/fugit2/view/components/file_tree_view.lua:9: in main chunk
        [C]: in function 'require'
        ...hare/nvim/rocks/rocks_rtp/lua/fugit2/view/git_status.lua:16: in main chunk
        [C]: in function 'require'
        ....local/share/nvim/rocks/share/lua/5.1/fugit2/view/ui.lua:19: in function 'new_fugit2_status_window'
        ...in/.local/share/nvim/rocks/share/lua/5.1/fugit2/init.lua:89: in function <...in/.local/share/nvim/rocks/share/lua/5.1/fugit2/init.lua:86>

Weird. Neither README, nor Installation Guide mentioned that I need nvim-web-devicons. I also expected Rocks to bring any dependencies that plugin has - after all it's the main selling point of using luarocks for plugins. I've also looked at other wiki pages and searched the issues but I've no mention of that dependency (even optional) and also haven't found an option to turn it off.

Describe the solution you'd like

Mention that you need to configure libgit2 path explicitly in the readme.

Make plugin log more user-frienly error in case libgit2 path isn't configured or something else is wrong with libgit2

Mention that nvim-web-dev-icons is required dependency or fix plugin crashing if it can't find it.

Installation guide could be more convenient if it was restructed into sections that go in order like libgit2 installation, plugin installation, plugin configuration where each section describes different ways/OS-specifics to achieve section goal instead of current inside-out approach where different ways/OSes are separate sections which we'll have to repeat same snippets for each OS.

Describe alternatives you've considered

Keep debugging this plugin until it finally works on my machine. Abandon this and try using another plugin. Keep using tig for git things.

Additional context

No response

SuperBo commented 1 week ago

Hi @Anrock, I'm very sorry to hear about your experience. As you can see in luarock package https://luarocks.org/modules/superbo/fugit2.nvim, nvim-web-devicons is already listed as dependencies, I don't know why it is not installed when you use with Rocks install. Can you share with me your config file so I can replicate this on my local machine.

About this suggestion Installation guide could be more convenient if it was restructed into sections that go in order like libgit2 installation, plugin installation, plugin configuration where each section describes different ways/OS-specifics to achieve section goal instead of current inside-out approach where different ways/OSes are separate sections which we'll have to repeat same snippets for each OS. I will restructure wiki following your suggestion. Thank you for this idea.

Anrock commented 1 week ago

@SuperBo don't be sorry and please excuse me if it sounded like some kind of personal attack.

Anyway, here's my config

Details ``` -- Rocks local rocks_config = { rocks_path = vim.fn.stdpath("data") .. "/rocks", luarocks_binary = "luarocks", } vim.g.rocks_nvim = rocks_config local luarocks_path = { vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?.lua"), vim.fs.joinpath(rocks_config.rocks_path, "share", "lua", "5.1", "?", "init.lua"), } package.path = package.path .. ";" .. table.concat(luarocks_path, ";") local luarocks_cpath = { vim.fs.joinpath(rocks_config.rocks_path, "lib", "lua", "5.1", "?.so"), vim.fs.joinpath(rocks_config.rocks_path, "lib64", "lua", "5.1", "?.so"), } package.cpath = package.cpath .. ";" .. table.concat(luarocks_cpath, ";") vim.opt.runtimepath:append(vim.fs.joinpath(rocks_config.rocks_path, "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*")) -- vim.g.mapleader = " " -- require "paq" { -- 'hrsh7th/cmp-calc'; -- 'hrsh7th/cmp-nvim-lua'; -- 'rasulomaroff/cmp-bufname'; -- 'hrsh7th/cmp-nvim-lsp-signature-help'; -- -- -- Other -- 'kana/vim-textobj-user'; -- } require('neorg').setup({ load = { ["core.defaults"] = {}, ["core.dirman"] = { config = { workspaces = { main = "~/Norg", }, default_workspace = "main", }, }, ["core.qol.toc"] = {}, ["core.summary"] = {}, ["core.completion"] = { config = { engine = "nvim-cmp", }, }, ["core.concealer"] = { config = { icons = { todo = { done = { icon = "✓" }, pending = { icon = "▶" }, uncertain = { icon = "⁇" }, on_hold = { icon = "⏸" }, cancelled = { icon = "⏏" }, undone = { icon = " " }, }, }, }, }, } }) require('fugit2').setup({ opts = { libgit2_path = '/usr/lib64/libgit2.so' } }) --require('gitsigns').setup() vim.filetype.add({ extension = { cf = "ebnf", -- For BNFC .cf files ltx = "ini", -- Stalker ini files script = "lua", -- Stalker lua scripts }, }) -- Diagram drawing vim.api.nvim_set_keymap('v', 'v', ':VBox', {silent = true, noremap = true}) -- Theme / statusline vim.opt.termguicolors = true vim.opt.background = 'dark' vim.cmd.colorscheme('gruvbox') require('feline').setup() -- LSP require('lsp') -- Completion vim.opt.completeopt = {'menuone', 'noinsert', 'noselect'} local cmp = require('cmp') cmp.setup({ snippet = { expand = function(args) -- Native neovim snippet support vim.snippet.expand(args.body) end }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), [''] = cmp.mapping.scroll_docs(4), [''] = cmp.mapping.complete(), [''] = cmp.mapping.abort(), [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources( { { name = 'nvim_lsp' }, }, { { name = 'buffer' }, }, { { name = 'bufname' }, }, { { name = 'calc' }, }, { { name = 'nvim_lsp_signature_help' } }, { { name = 'path', option = { trailing_slash = true } } }, { { name = 'nvim_lua' } } ), }) -- Set configuration for specific filetype. cmp.setup.filetype('gitcommit', { sources = cmp.config.sources({ { name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git). }, { { name = 'buffer' }, }) }) -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline({ '/', '?' }, { mapping = cmp.mapping.preset.cmdline(), sources = { { name = 'buffer' } } }) -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore). cmp.setup.cmdline(':', { mapping = cmp.mapping.preset.cmdline(), sources = cmp.config.sources({ { name = 'path', option = { trailing_slash = true } } }, { { name = 'cmdline' } }) }) vim.api.nvim_set_keymap('n', 'ff', 'Telescope find_files', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fg', 'Telescope live_grep', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fr', 'Telescope lsp_references', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fd', 'Telescope diagnostics bufnr=0', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fD', 'Telescope diagnostics', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fs', 'Telescope lsp_document_symbols', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fS', 'Telescope lsp_dynamic_workspace_symbols', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fb', 'Telescope buffers', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fi', 'Telescope lsp_incoming_calls', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fo', 'Telescope lsp_outgoing_calls', {silent = true, noremap = true}) vim.api.nvim_set_keymap('n', 'fR', 'Telescope resume', {silent = true, noremap = true}) require('oil').setup() vim.api.nvim_set_keymap('n', 'o', 'Oil --float', {silent = true, noremap = true}) require('neovide') -- Indents vim.opt.listchars = { tab = '│·', extends = '⟩', precedes = '⟨', trail = '·' } vim.opt.list = true vim.opt.cursorline = true vim.opt.cursorcolumn = true vim.opt.colorcolumn = '80' vim.opt.textwidth = 80 vim.opt.softtabstop = 2 vim.opt.expandtab = true vim.opt.smartindent = true vim.opt.tabstop = 2 vim.opt.shiftwidth = 2 -- Sign column vim.opt.number = true -- Search vim.opt.inccommand = 'split' vim.opt.showmatch = true vim.opt.ignorecase = true vim.opt.smartcase = true vim.opt.shortmess = 'c' -- Netrw vim.g.netrw_liststyle = 3 vim.g.netrw_banner = 0 vim.g.netrw_preview = 1 -- Misc vim.opt.showmode = false vim.opt.mouse = 'a' vim.opt.updatetime = 300 vim.opt.scrolloff = 3 vim.opt.langmap = 'ФИСВУАПРШОЛДЬТЩЗЙКЫЕГМЦЧНЯЖ;ABCDEFGHIJKLMNOPQRSTUVWXYZ:,фисвуапршолдьтщзйкыегмцчня;abcdefghijklmnopqrstuvwxyz' vim.opt.belloff = vim.opt.belloff + 'ctrlg' vim.opt.conceallevel = 2 ```

And rocks.toml file

Details ``` # This is your rocks.nvim plugins declaration file. # Here is a small yet pretty detailed example on how to use it: # # [plugins] # nvim-treesitter = "semver_version" # e.g. "1.0.0" # List of non-Neovim rocks. # This includes things like `toml` or other lua packages. [rocks] [treesitter] auto_highlight = "all" auto_install = "prompt" # List of Neovim plugins to install alongside their versions. # If the plugin name contains a dot then you must add quotes to the key name! [plugins] "rocks.nvim" = "2.31.3" "fidget.nvim" = "1.4.1" "gruvbox.nvim" = { version = "2.0.0", opt = true } "oil.nvim" = "2.10.0" "telescope.nvim" = "scm" "venn.nvim" = "scm" "which-key.nvim" = "2.1.0" cmp-buffer = "scm" cmp-cmdline = "scm" cmp-nvim-lsp = "scm" cmp-path = "scm" neorg = { version = "8.7.1" } nvim-lspconfig = "0.1.8" "rocks-treesitter.nvim" = "scm" tree-sitter-toml = "scm" tree-sitter-lua = "scm" tree-sitter-haskell = "scm" tree-sitter-ebnf = "scm" tree-sitter-markdown = "scm" "feline.nvim" = "1.6.2" tree-sitter-starlark = "scm" tree-sitter-make = "scm" tree-sitter-bash = "scm" tree-sitter-c = "scm" tree-sitter-cmake = "scm" tree-sitter-kconfig = "scm" tree-sitter-yaml = "scm" "rocks-git.nvim" = "1.5.1" tree-sitter-norg-meta = "0.1.0" tree-sitter-python = "scm" tree-sitter-vimdoc = "scm" "fugit2.nvim" = "0.2.0" nvim-cmp= "scm" [plugins.nvim-treesitter] git = "nvim-treesitter/nvim-treesitter" rev = "v0.9.2^{}" ```

One interesting thing I've noticed is that while devicons are indeed in dependency file - Rocks install it. But I do have other deps: nui and plenary (maybe from other plugins). Could be an issue with Rocks actually.

SuperBo commented 1 week ago

thank @Anrock, I need to create an isolated neovim config to test your config, so it may take a while. Do you manage to run Fugit2?

P/s: nui and plenary is also in dependencies list. You can see lazy.nvim config to see all dependencies :D

Anrock commented 1 week ago

Oops, I messed up my previous message. What I meant is that nui and plenary were installed by Rocks but nvim-web-devicons wasn't, for some reason. But I probably had nui and plenary because I have neorg installed. Could be something wrong with Rocks.

Anyway, I installed devicons manually via Rocks and Fugit2 starts without errors now.

SuperBo commented 1 week ago

@Anrock, I write a dedicated part for libgit2 installation. https://github.com/SuperBo/fugit2.nvim/wiki/Install-libgit2. Do you have anything to add?

Anrock commented 1 week ago

@SuperBo I guess no, except it seems it's just a copy of whatever was before in installation guide? With same config copypasted under each section for each OS over and over. I was thinking about remaking installation guide into something like:

Install Fugit2

Rocks

:Rocks install fugit2.nvim

Lazy

whatever is needed for lazy

Some other package manager

...

Install libgit2

Ubuntu

sudo apt-get install libgit2

Arch Linux

sudo pacman -S libgit2

some other OS

...

Specify path to libgit2 in Fugit2 setup

how to get actual path to libgit2.so goes here

Lazy

-- Fugit2 setup table
{
  libgit2_path = 'libgit2.so.1.7',
  ...
}

Rocks

require('fugit2.nvim').setup({ libgit2_path = ... })

some other package manager

...

bitterjug commented 6 days ago

Hi. I'm here with the same problem after searching for "attempt to index field 'C'" Today I was excited to see fugit2 and wanted to try it. I installed an appimage of neovim 10 specially for the purpose. And installed Rocks because that's what the readme said. (My other config uses lazy).

Then I did Rocks install fugit2.nvim because that's what the Readme said. (I was also curious to try out Rocks for first time) image

Running :Fugit2 now gives:

Error executing Lua callback: ...cal/share/nvim-rocks/rocks/rocks_rtp/lua/fugit2/git2.lua:1972: attempt to index field 'C' (a nil value)
stack traceback:
        ...cal/share/nvim-rocks/rocks/rocks_rtp/lua/fugit2/git2.lua:1972: in function 'open'
        ...cal/share/nvim-rocks/rocks/rocks_rtp/lua/fugit2/init.lua:68: in function 'open_repository'
        ...cal/share/nvim-rocks/rocks/rocks_rtp/lua/fugit2/init.lua:87: in function <...cal/share/nvim-rocks/rocks/rocks_rtp/lua/fugit2/init.lua:86>

nvim

:version
NVIM v0.10.0
Build type: Release
LuaJIT 2.1.1713484068
Run ":verbose version" for more info

Pasted the sample lazy config into my lazy settings but I still ge the same message. So I need to add this: image but where does it go? I tried putting it into opts along with the width setting from the sample lazy config

  opts = {
    width = 70,
    libgit2_path = 'libgit2.so.1.1',
  },

Great, now I get a different error

Error executing Lua callback: ...ickstart-modular/lazy/fugit2.nvim/lua/fugit2/view/ui.lua:19: loop or previous error loading module 'fugit2.view.git_status'
stack traceback:
        [C]: in function 'require'
        ...ickstart-modular/lazy/fugit2.nvim/lua/fugit2/view/ui.lua:19: in function 'new_fugit2_status_window'
        ...m-kickstart-modular/lazy/fugit2.nvim/lua/fugit2/init.lua:70: in function <...m-kickstart-modular/lazy/fugit2.nvim/lua/fugit2/init.lua:66>

Restarted nivm and now it works.

So I tripped up in a similar way to the OP.

SuperBo commented 6 days ago

@bitterjug, sorry for your experience. I didn't test with rocks installation before :(. I will try to fix this asap T_T.

SuperBo commented 2 days ago

hi @bitterjug, @Anrock can you test new installation guide mentioned here.

Anrock commented 2 days ago

@SuperBo looks great. Small nitpicks/suggestions:

SuperBo commented 2 days ago

hi @Anrock, actually libgit2_path = "libgit2" is already the default value. However the problem with my plugin is that the setup function must be called once to set it up. So, the actual usage of section [plugins."fugit2.nvim".config] is just triggering setup function call.

For require('fugit2.nvim').setup(...), where do you put it? In init.lua (after Rocks.nvim setup) or in a separate file?

For versioning problem, as long as we don't specify pin=true, we can always update fugit2.nvim by :Rocks update command.

Do you think it will be better if I separate Rocks installation guide from lazy.nvim?

Anrock commented 2 days ago

actually libgit2_path = "libgit2" is already the default value.

My bad, I missed it.

For require('fugit2.nvim').setup(...), where do you put it?

Just somewhere in init.lua after rock setup, yes.

For versioning problem, as long as we don't specify pin=true, we can always update fugit2.nvim by :Rocks update command.

Ah, I stand corrected about being stuck in specific version then. However fugit won't be updated unless user explicitly executes :Rocks update after installing then, no?

Do you think it will be better if I separate Rocks installation guide from lazy.nvim?

No strong opinion on this. I have a feeling that actually both guides can be in one page actually without it being too long if structured properly.

SuperBo commented 2 days ago

@Anrock, I updated this guide https://github.com/SuperBo/fugit2.nvim/wiki/%F0%9F%93%A6-Installation

the version is removed, plain lua config is provided beside rocks-config.nvim

Anrock commented 2 days ago

@SuperBo LGTM. I consider this issue resolved (w.r.t. my specific setup) unless @bitterjug has something else to add.

SuperBo commented 2 days ago

I will update README.md then close this issue later. @Anrock Thank you again for your contribution :D