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

bug: override not working #108

Closed
3 tasks done
zegervdv opened this issue Jan 14, 2023 · 10 comments · Fixed by #107
Closed
3 tasks done

bug: override not working #108

zegervdv opened this issue Jan 14, 2023 · 10 comments · Fixed by #107
Labels
bug Something isn't working

Comments

@zegervdv
Copy link

Did you check docs and existing issues?

  • I have read all the neodev.nvim docs
  • I have searched the existing issues of neodev.nvim
  • I have searched the exsiting issues of plugins related to this issue

Neovim version (nvim -v)

0.8.2

Operating system/version

Ubuntu 22.04

Describe the bug

I'm using chezmoi to manage my dotfiles, and as such my init.lua is not in the default location.
I use the override option to setup to enable neodev in the chezmoi folder:

  override = function(root_dir, options)
    vim.pretty_print('ROOT: ' .. root_dir)
    if require('neodev.util').has_file(root_dir, os.getenv('HOME') .. '/.local/share/chezmoi') then
      options.enabled = true
      options.runtime = true
      options.types = true
      options.plugins = true
    end
  end,
}

Since a34a9e7 that function does not seem to be working anymore (or even called?)
The debug print I have in there is no longer showing up in the messages.

Steps To Reproduce

  1. Have non-default location of init.lua
  2. set the override option

Expected Behavior

Have the override option (or something equivalent) work again :)

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  "folke/neodev.nvim",
  -- add any other plugins here
  'neovim/nvim-lspconfig',
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

require('neodev').setup {
  override = function (root_dir, options)
    print('hello')
  end
}

require('lspconfig').sumneko_lua.setup {}
@zegervdv zegervdv added the bug Something isn't working label Jan 14, 2023
@folke
Copy link
Owner

folke commented Jan 14, 2023

That has_file was an internal function, but I removed that since it's no longer used.

change it to if root_dir:find("chezmoi") then or something similar

@folke folke closed this as completed Jan 14, 2023
@zegervdv
Copy link
Author

I don't think it is calling the override function anymore. In the repro.lua I've added a print which is no longer showing up since that commit.

@folke folke reopened this Jan 14, 2023
@folke
Copy link
Owner

folke commented Jan 14, 2023

Closing again. It does work for me.
Use vim.notify("hello") to see the message

@folke folke closed this as completed Jan 14, 2023
@zegervdv
Copy link
Author

Okay, must be something with my machine then. Even in a docker container the notify doesn't show up.

@folke
Copy link
Owner

folke commented Jan 15, 2023

The notify will only come up when lspconfig is configured

@zegervdv
Copy link
Author

zegervdv commented Jan 15, 2023

I added some prints and found out that in lsp.lua lua_root is nil, which causes #lua_root to error silently.
When changing ... and #lua_root to ... and lua_root and #lua_root it does continue to calling the override function.
Since I'm not in a lua plugin directory, there is no lua folder

@folke
Copy link
Owner

folke commented Jan 15, 2023

Good catch. Fixed!

@zegervdv
Copy link
Author

Thanks!

@Congee
Copy link

Congee commented Jun 27, 2023

That has_file was an internal function, but I removed that since it's no longer used.

change it to if root_dir:find("chezmoi") then or something similar

neodev.nvim/README.md

Lines 108 to 124 in 2e53151

<details>
<summary>Example for setting up **neodev** that overrides the settings for `/etc/nixos`</summary>
```lua
-- You can override the default detection using the override function
-- EXAMPLE: If you want a certain directory to be configured differently, you can override its settings
require("neodev").setup({
override = function(root_dir, library)
if require("neodev.util").has_file(root_dir, "/etc/nixos") then
library.enabled = true
library.plugins = true
end
end,
})
```
</details>

Then, this instruction in README is outdated, right?

@folke
Copy link
Owner

folke commented Jun 27, 2023

correct. just updated the readme

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants