Fork me on GitHub
#conjure
<
2023-06-01
>
Dumch07:06:14

Hey, guys! Do you know if there is a way to evaluate some mapping only for buffers where conjure is used (fennel, clojure, shceme)?

armed09:06:21

Hi, you can create file type based autocommand which assigns mappings in the current buffer.

armed09:06:02

`-- close some filetypes with <q> autocmd("FileType", { group = general, pattern = { "qf", "help", "man", "notify", "lspinfo", "spectre_panel", "startuptime", "tsplayground", "nvim-docs-view", "PlenaryTestPopup", }, callback = function(event) http://vim.bo[event.buf].buflisted = false vim.keymap.set("n", "q", "<cmd>close<cr>", { buffer = event.buf, silent = true }) end, desc = "Close by q", })` Here is an example in nvim lua

Olical09:06:06

Hmm I was thinking of recommending the custom autocmds Conjure emits https://github.com/Olical/conjure/blob/1dd96d90f53122225f698e58b50dee9ed760cf2e/doc/conjure.txt#L848-L885 Or even hooks https://github.com/Olical/conjure/blob/1dd96d90f53122225f698e58b50dee9ed760cf2e/doc/conjure.txt#L1122-L1167 But neither of those have things to do with "Conjure loaded for this buffer!" yet. Could be added though, might be a really useful feature. Technically you could hook into the HUD hook since that pops up on first load of a buffer usually (unless you turn it off). But you'd need to ensure your code only ran on the first HUD pop up for each buffer or waste setting up the same mappings over and over.

2
Olical09:06:20

I think there's an argument to be made here for a new autocmd or hook for this sort of thing.

Leaf Garland02:06:47

That's what LSP does with the https://neovim.io/doc/user/lsp.html#lsp-events events. Instead of doing LSP setup per file type, have an autocmd for that event that does LSP maps etc.

practicalli-johnny12:06:06

I've created a https://github.com/AstroNvim/astrocommunity/pull/248 using Conjure, which works very well once a localleader is mapped (in the AstroNvim user config for now). The AstroNvim maintainer will add a localleader in the next release of AstroNvim, which is nice 😄

practicalli-johnny12:06:29

Is there a good Lua equivalent of this https://github.com/Olical/conjure/issues/427#issuecomment-1271020140?

autocmd BufNewFile conjure-log-* lua vim.diagnostic.disable(0)
I've got this far.. not sure if its right.. but it seems to work. Any lua tweaks appreciated...
vim.api.nvim_create_autocmd("BufNewFile", {
        -- group = vim.api.nvim_create_augroup("conjure_log_disable_lsp", { clear = true }),
        pattern = { "conjure-log-*" },
        callback = function() vim.diagnostic.disable(0) end,
        desc = "Conjure Log disable LSP diagnostics",
      })
Not sure if I need an augroup, seems to work without one...

Olical13:06:49

That looks good to me! Here's an example of how I define an augroup + autocmd in fennel https://github.com/Olical/conjure/wiki/Integrating-with-Clay-and-data-visualisation-tools

👍 2
Olical13:06:01

And the AstroNvim part is really cool, thank you so much!

👍 2
practicalli-johnny14:06:12

AstroNvim Clojure pack is merged now and the localleader is in the AstroNvim nightly build for the upcoming release. I'm writing up the AstroNvim config and Clojure workflow in https://practical.li/neovim/ over the next few days.