SmiteshP / nvim-gps

Simple statusline component that shows what scope you are working inside
Apache License 2.0
479 stars 46 forks source link

no output with lualine.nvim #59

Closed steven-omaha closed 2 years ago

steven-omaha commented 2 years ago

Thank you for writing and maintaining this project!

I am on neovim-0.6.1. I am aware of #55, but that doesn't seem to fix the problem for me.

Problem: I do not see an output in lualine.

screen

The relevant part of my vimrc are (code copy and pasted from README.md)

  Plugin 'nvim-lualine/lualine.nvim'
  " icons for lualine
  Plugin 'kyazdani42/nvim-web-devicons'
  Plugin 'nvim-treesitter/nvim-treesitter'
  Plugin 'SmiteshP/nvim-gps'

" ------------------------------------------------------------------
" lualine.nvim, nvim-gps
" ------------------------------------------------------------------

lua << END
local gps = require("nvim-gps")

require("lualine").setup({
  sections = {
    lualine_c = {
      { gps.get_location, cond = gps.is_available },
    }
  }
})
END

My complete vimrc is this: https://gist.github.com/steven-omaha/0ed4f29b6fd196a0a058ecb7c3ec4e6b

SmiteshP commented 2 years ago

Seems like you forgot to run the setup function. Just add the following line before lualine's setup

require("nvim-gps").setup()

So it would look like this

lua << END
local gps = require("nvim-gps")

gps.setup()

require("lualine").setup({
  sections = {
    lualine_c = {
      { gps.get_location, cond = gps.is_available },
    }
  }
})
END
steven-omaha commented 2 years ago

Thanks for the quick reply! I have now copy-pasted your second code block into my vimrc. Unfortunately, I still don't get any output in my status bar.

SmiteshP commented 2 years ago

Could you try this? keep your cursor somewhere inside a scope (function or class) and then run the following command

:lua print(require("nvim-gps").get_location())

let me know if this prints something

steven-omaha commented 2 years ago
E5108: Error executing lua /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: no parser for 'python' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:25: in function 'require_language'
        /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:159: in function 'get_query'
        ...vim/bundle/nvim-treesitter/lua/nvim-treesitter/query.lua:91: in function 'get_query'
        ...e/timeshifter/.vim/bundle/nvim-gps/lua/nvim-gps/init.lua:228: in function 'get_location'
        [string ":lua"]:1: in main chunk
steven-omaha commented 2 years ago

What's interesting is that when I execute :TSUpdate, treesitter tells me it is up to date already.

SmiteshP commented 2 years ago

Looks like you haven't installed the treesitter parser. Try this

:TSInstall python

nvim-gps won't give you any output if there is no parser installed for that particular language.

steven-omaha commented 2 years ago

That fixed it. Thanks!

OlegGulevskyy commented 2 years ago

Hi @SmiteshP , I am having the same issue, however I do not have any errors when running this

:lua print(require("nvim-gps").get_location())

It correctly shows a path where the cursor is. However, inside the lualine there is no output at all.

image

I import nvim-gps like so

local gps = require("nvim-gps")
gps.setup()

And add it to the lualine like so:

lualine.setup {
  options = {
    globalstatus = true,
    icons_enabled = true,
    theme = "auto",
    component_separators = { left = "", right = "" },
    section_separators = { left = "", right = "" },
    disabled_filetypes = { "alpha", "dashboard" },
    always_divide_middle = true,
  },
  sections = {
    lualine_a = { "mode" },
    lualine_b = {"branch"},
    lualine_c = { diagnostics, { "nvim-gps", gps.get_location, cond = gps.is_available } },
    lualine_x = { diff, spaces, "encoding", filetype },
    lualine_y = { location },
    lualine_z = { "progress" },
  },
}

I have also tried without "nvim-gps" string literal in the table, like so:

    lualine_c = { diagnostics, { gps.get_location, cond = gps.is_available } },

No luck

image