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

errors with some features #8

Open
RojJuan opened this issue Mar 30, 2024 · 2 comments
Open

errors with some features #8

RojJuan opened this issue Mar 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@RojJuan
Copy link

RojJuan commented Mar 30, 2024

I found out about this plugin on the internet yesterday and it's very good, but i have some issues,

  1. Whenever i save, neovim spits out the errors bellow.
  2. To reproduce, use the Lazy config and Null-ls config below

Hope this can be fixed!

Error detected while processing BufWritePre Autocommands for "<buffer=1>":
Error executing lua callback: ....local/share/nvim/lazy/csharp.nvim/lua/csharp/config.lua:68: attempt to index global 'Csharp' (a nil value)
stack traceback:
....local/share/nvim/lazy/csharp.nvim/lua/csharp/config.lua:68: in function 'get_config'
...nvim/lazy/csharp.nvim/lua/csharp/features/fix-usings.lua:25: in function 'fix_usings'

---------------------------Another error-------------------------

Failed to run config for csharp.nvim

/home/kingboo/.config/nvim/lua/custom/plugins.lua:161: attempt to index field 'dap' (a nil value)

stacktrace:

  • ~/.config/nvim/lua/custom/plugins.lua:161 in config
  • ~/.config/nvim/lua/custom/configs/null-ls.lua:37

Plugins.lua

},
    config = function()
      require("mason").setup()

      if require("csharp") and require("csharp").lsp then
        require("csharp").lsp.enable = false
      end

      require("csharp").dap.adapter_name = "netcorebg"
      require("csharp").setup()
      require("csharp").debug_project()
      require("csharp").run_project()
      require("csharp").fix_usings()
      require("csharp").fix_all()
      require("csharp").go_to_definition()
    end,
},

Null-ls.lua

  callback = function(args)
    vim.api.nvim_create_autocmd("BufWritePre", {
      group = augroup,
      buffer = args.buf,
      callback = function()
        vim.lsp.buf.format({ timeout = 1000, async = false })

        if vim.bo[0].filetype == "cs" then
          require("csharp").fix_usings()
        end
      end,
    })
  end
})
return opts
@iabdelkareem iabdelkareem added the bug Something isn't working label Apr 3, 2024
@iabdelkareem
Copy link
Owner

Thank you for reporting. Unfortunately, I don't have time at the moment to look into it :( I appreciate any contribution if you can, otherwise, I'll start looking into it once I get the chance.

@alsi-lawr
Copy link

@theonekingboo
Not a bug.

It's a misunderstanding of how to setup the plugin.

If you want to override the dap, it should look like:

require("csharp").setup({
  dap = {
    adapter_name = "netcoredbg",
  },
  -- other config here
})

And running this on configure makes no sense as there's no context for these actions to do anything. These functions are run on a project context or a buffer, not for initialising any functionality.

require("csharp").debug_project()
require("csharp").run_project()
require("csharp").fix_usings()
require("csharp").fix_all()
require("csharp").go_to_definition()

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

No branches or pull requests

3 participants