Giter Club home page Giter Club logo

Comments (9)

practicalli-johnny avatar practicalli-johnny commented on June 8, 2024

I used an autocmd to disable diagnostics in any buffer matching clojure-log-*

https://github.com/practicalli/astronvim-user-config/blob/401744a2d137c9cf06b6247de5ae72c38f9a1be1/lua/plugins/clojure.lua#L217

I assume something similar to disable Treesitter may be effective (but just a guess)

from conjure.

PaterJason avatar PaterJason commented on June 8, 2024

On LSP, the lspconfig plugin sets autocommands on FileType to autostart servers. There is a catch for the buffer option buftype=nofile, but for log buffers this looks like it's set after the autocmd fires.

I quickly hacked this together to demonstrate. nvim.fn.bufload was setting the filetype, and I had to explicitly set the filetype after.
PaterJason@768580b#diff-e0903b23fec5b0ccc884fe0be027056d0a7bb5c55bb73ecc58a0d56377353811

from conjure.

Olical avatar Olical commented on June 8, 2024

Oh interesting! So maybe if I just change the order of the buftype setting it'd help some people out. I kind of like the LSP / linting in the log buffer because it helps me autocomplete, doc lookup and edit the contents in the same way as I would a normal buffer.

I get that some people wouldn't want that but this is why I opted (in the past) to say "disable it yourself" rather than disabling it by default in such a way that people couldn't turn it back on.

If I change the order and set buftype before the autocmd fires, I guess it turns off LSP for the log buffer? (in theory)

In doing so, do I remove the ability for anyone to use LSP in the log without some hacking? Is there an easy way to then selectively turn it on for the users that do want the log to have LSP?

Maybe if nofile doesn't really do much for us (I feel like it does?) we could move it so it's set at the right time and then make it optional so people can ignore the nofile option, thus kinda making an LSP toggle, although an indirect one.

Of course this behaviour will change / break if the plugins we're trying to toggle change their behaviour. Which is another reason I never wanted to do this from Conjure's side. Conjure makes a Clojure buffer, your plugins hook into that buffer, I mostly feel like it's the duty of those plugins to be easily configurable to NOT fire for some buffers or patterns and I shouldn't try to actively block plugins from hooking into the log buffer since there could be infinitely many plugins and they may change behaviour from under me.

So I'm not 100% settled on the way forward yet, but this is really interesting information and I'd like to find a solution that keeps both camps happier for the long term (people who want linting in the log and people who don't).

from conjure.

dradtke avatar dradtke commented on June 8, 2024

One thing to note here is that there are really two different kinds of Clojure: one that you might see in a source file, and one that you see in a REPL (or the log buffer). As a quick example, here's what I see when I evaluate a simple source file:

image

clojure-lsp understands the source file, but it doesn't seem to really understand the log buffer. This is the type of diagnostic warning that I was looking to avoid, since evaluating larger files results in the log buffer filling up with errors.

So, one possible solution for me would be to somehow tell clojure-lsp that the log buffer should be evaluated within the context of the project, rather than as a standalone file. I'm not sure if that's possible, but it would be nice to keep LSP and diagnostics enabled if they can actually be useful.

from conjure.

PaterJason avatar PaterJason commented on June 8, 2024

Having a look, lspconfig doesn't want to attach at all to nofile buffers, using either :LspStart or the autostart. Stopping and starting wouldn't attach to an open log buffer for example. Which makes sense, a nofile is not really part of the workspace. You can force it by starting the server using the builtin lua, which is relatively simple nowadays.

vim.lsp.start({
  name = "clojure_lsp",
  cmd = { "clojure-lsp" },
  root_dir = vim.fs.root(
    0,
    { "project.clj", "deps.edn", "build.boot", "shadow-cljs.edn", ".git", "bb.edn" }
  ),
})

And trigger that by autocmd. But if you wanted to do that for each filetype I can see it being a pain.

Personally I'd set the buffer options before FileType autocmds, cos setting it after would potentially circumvent the intent in the lspconfig or other plugin/config.

from conjure.

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.