Giter Club home page Giter Club logo

Comments (18)

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024 1

Turns out you can!

My mistake is that I was doing lua require('otter').activate({'elixir'}) instead of lua require('otter').activate({'markdown'})

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024 1

Big up for the issue title! 🦦

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024 1

Just need a small fix here: e302002#r130924812

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024 1

Wrote about otter in Elixir Forum:
https://elixirforum.com/t/grammar-style-check-and-markdown-linter-for-code-documentation-in-neovim/59248

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024

Sorry to bump this again,

My markdown files are using ltex-ls and vale-ls.

In the markdown inside Elixir files, I got ltex-ls working, but only because it works with plaintext files (and then it gives me a lot of diagnostics that doesn't make sense in Markdown):

[ERROR][2023-10-24 18:24:23] .../vim/lsp/rpc.lua:675    "rpc"   "ltex-ls"       "stderr"        "Oct 24, 2023 6:24:23 PM org.bsplines.ltexls.parsing.CodeFragmentizer$Companion create\nWARNING: Unsupported code language ID '', treating text as plaintext\n"

So it seems to me that otter is generating buffers with no filetype set. How can I debug it further? (I'm using Neovim nightly, btw)

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

Indeed, for performance reasons I don't set the ft of the otter buffer:

-- manually attach language server the corresponds to the fileytype
-- without setting the filetype
-- to prevent other plugins we don't need in the otter buffers
-- from automatically attaching when ft is set
for _, lang in ipairs(languages) do
local otter_nr = M._otters_attached[main_nr].buffers[lang]
local autocommands = api.nvim_get_autocmds({ group = "lspconfig", pattern = lang })
for _, command in ipairs(autocommands) do
local opt = { buf = otter_nr }
command.callback(opt)
end

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

So any languageserver configured to attach to the would-be-filtetype of the otter buffer should still be attached because lspconfig creates the autocommand whose callback we call here.

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024

So any languageserver configured to attach to the would-be-filtetype of the otter buffer should still be attached because lspconfig creates the autocommand whose callback we call here.

interesting!

I added some vim.inpects to see what's going on:

main_nr: 1
lang: "markdown"
otter_nr: 3
autocommands: { {
    buflocal = false,
    callback = <function 1>,
    command = "",
    desc = "Checks whether server marksman should start a new instance or attach to an existing one.",
    event = "FileType",
    group = 26,
    group_name = "lspconfig",
    id = 62,
    once = false,
    pattern = "markdown"
  }, {
    buflocal = false,
    callback = <function 2>,
    command = "",
    desc = "Checks whether server vale_ls should start a new instance or attach to an existing one.",
    event = "FileType",
    group = 26,
    group_name = "lspconfig",
    id = 64,
    once = false,
    pattern = "markdown"
  }, {
    buflocal = false,
    callback = <function 3>,
    command = "",
    desc = "Checks whether server ltex should start a new instance or attach to an existing one.",
    event = "FileType",
    group = 26,
    group_name = "lspconfig",
    id = 77,
    once = false,
    pattern = "markdown"
  } }
diagnostics: true

But no luck with marksman and vale attaching to the otter buffer yet. Still investigating. If you have any pointers, please let me know.

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

I guessing they are being attached and immediately quit because they require a filetype? Does the lsp log show something?

Maybe I can revert to setting the filetype instead of manually calling the callbacks. I believe I have since made other performance improvements that may make this "hack" obsolete.

Can you try this?

    -- local autocommands = api.nvim_get_autocmds({ group = "lspconfig", pattern = lang })
    -- for _, command in ipairs(autocommands) do
    --   local opt = { buf = otter_nr }
    --   command.callback(opt)
    -- end
    api.nvim_buf_set_option(otter_nr, "filetype", lang)

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024

Can you try this?

    -- local autocommands = api.nvim_get_autocmds({ group = "lspconfig", pattern = lang })
    -- for _, command in ipairs(autocommands) do
    --   local opt = { buf = otter_nr }
    --   command.callback(opt)
    -- end
    api.nvim_buf_set_option(otter_nr, "filetype", lang)

That worked for ltex-ls, which was already attaching to the otter buffer. Now ltex-ls parses it as a Markdown code correctly:
CleanShot 2023-10-25 at 12 44 28

This is great already!

Now, I still wonder why the other LSPs are not attaching. In particular, I'm interested in vale-ls, but the lsp logs show nothing.

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

Does vale attach correctly to regular markdown buffers?

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

You can also directly open the otter buffer (:ls! to see which number it has, then :b<number>) and experiment in it.

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024

Does vale attach correctly to regular markdown buffers?

It does. But I managed to get everything working. My problem is that I had installed (through Mason) both vale and vale-ls. As soon as I uninstalled vale, it worked as expected:

CleanShot 2023-10-25 at 15 46 25

Now, I still need to set filetype for ltex-ls in order to ignore some errors that don't make sense for Markdown, so that the final result is:

CleanShot 2023-10-25 at 15 48 48

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024

Thanks a lot for helping me through it! I didn't know about ls!, that was really helpful.

Are you going to reenable filetype? I guess it would only benefit users of ltex on embedded markdown, so, not sure if you want to go that path, although I'd be glad if you did :)

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

I haven't found performance degradation from re-enabling filetypes on otter bufffers in my config so far, so I might. But I am wary about people's filetype plugins doing weird things to the otter buffers or running a lot more code than they have to. You know what, we can just leave both options in and make it configurable.

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

the release bot misunderstood my refs, was not supposed to close this. Let me know how this change works for you.

from otter.nvim.

georgeguimaraes avatar georgeguimaraes commented on July 30, 2024

Everything working perfectly (saw the new release)! Thanks again so much. And I apologize for all the trouble in helping me

from otter.nvim.

jmbuhr avatar jmbuhr commented on July 30, 2024

I thank you for your contribution! :)

from otter.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.