Coder Social home page Coder Social logo

Comments (5)

preiter93 avatar preiter93 commented on September 26, 2024 1

I have noticed something similar too, namely when trying to auto format on save, it isn't formatting. Guessing this is related?

yes, probably, that's how I noticed it too. I think it's common to have code like this

-- Autoformatting on save
if client.supports_method(“textDocument/formatting”) then
  vim.api.nvim_create_autocmd(“BufWritePre”, {
    buffer = bufnr,
    callback = function()
      vim.lsp.buf.format({ bufnr = bufnr })
    end,
  })
end

which runs in the lsps on_attach. Thats is currently not working. As a workaround I removed the check

if client.supports_method(“textDocument/formatting”) then

for flutter/dart.

from flutter-tools.nvim.

JordanllHarper avatar JordanllHarper commented on September 26, 2024

I have noticed something similar too, namely when trying to auto format on save, it isn't formatting. Guessing this is related?

from flutter-tools.nvim.

CnTeng avatar CnTeng commented on September 26, 2024

Close the opened flutter buffer, and reopen it.
Then all the supports_method check will pass, and inlay_hint will show correctly.
It's weird, but works.

from flutter-tools.nvim.

sidlatau avatar sidlatau commented on September 26, 2024

I think this is related to neovim/neovim#23681, now document formatting, code actions, and inlay hints have the property dynamicRegistration=true. If I set it to false here https://github.com/akinsho/flutter-tools.nvim/blob/990a1349c29f7d474a0cd51355aba773ccc9deea/lua/flutter-tools/lsp/init.lua#L95 or in local config then client.supports_method(“textDocument/formatting”) returns true. But I am not sure what is the correct fix here...

from flutter-tools.nvim.

sidlatau avatar sidlatau commented on September 26, 2024

I investigated this a bit more, here is more information about the problem: neovim/neovim#24229

It is not enough now to check capabilities on LspAttach, it may return false, but then the capability may be registered dynamically and the next check will return true.
Workarounds for this may be to switch back to static registration:

flutter_tools.setup {
  lsp = {
    capabilities = {
      textDocument = { formatting = { dynamicRegistration = false } },
    },
}

Or do additional check in client/registerCapability handler:

local orig_handler = vim.lsp.handlers["client/registerCapability"]
vim.lsp.handlers["client/registerCapability"] = function(err, result, ctx)
  local orig_result = orig_handler(err, result, ctx)
   -- do something
  return orig_result
end

As this is not a plugin bug I will close this issue.

from flutter-tools.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.