mirror of
https://github.com/LazyVim/LazyVim.git
synced 2026-11-25 17:14:20 +01:00
## Summary
The Conjure spec calls `require("conjure.mapping")["on-filetype"]()`
unconditionally in its `config` function. Because the plugin loads on
`event = "LazyFile"` (any file open), this sets Conjure's buffer-local
keymaps on whatever buffer triggered the load, regardless of filetype.
This call is redundant. `require("conjure.main").main()` internally
calls `mapping.init(filetypes)`, which:
1. Registers a `FileType` autocmd scoped to supported filetypes.
2. Checks if the current buffer's filetype is in the list before calling
`on-filetype()`.
From `conjure/mapping.lua`:
```lua
M.init = function(filetypes)
local group = vim.api.nvim_create_augroup("conjure_init_filetypes", {})
if (true == config["get-in"]({"mapping", "enable_ft_mappings"})) then
vim.api.nvim_create_autocmd("FileType", {
group = group, pattern = filetypes,
callback = autocmd_callback(M["on-filetype"])
})
if core.some(function(x) return x == vim.bo.filetype end, filetypes) then
vim.schedule(M["on-filetype"])
end
end
end
```
The extra `on-filetype()` bypasses this guard. Removing it restores the
intended behavior: Conjure keymaps only appear in buffers whose filetype
Conjure supports.
## Related Issue(s)
Fixes #7064
## Repro
Save as `repro.lua` and run with `nvim -u repro.lua`:
```lua
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
{ import = "lazyvim.plugins.extras.lang.clojure" },
},
})
```
Steps:
1. `nvim -u repro.lua`
2. `:e test.md`
3. `:nmap <localleader>` — observe 25+ Conjure keymaps on a markdown
buffer
After this fix, `:nmap <localleader>` on `test.md` shows no Conjure
keymaps.
## Checklist
- [x] I've read the
[CONTRIBUTING](https://github.com/LazyVim/LazyVim/blob/main/CONTRIBUTING.md)
guidelines.
99 lines
2.8 KiB
Lua
99 lines
2.8 KiB
Lua
return {
|
|
recommended = function()
|
|
return LazyVim.extras.wants({
|
|
ft = { "clojure", "edn" },
|
|
root = { "project.clj", "deps.edn", "build.boot", "shadow-cljs.edn", "bb.edn" },
|
|
})
|
|
end,
|
|
|
|
-- Add Clojure & related to treesitter
|
|
{
|
|
"nvim-treesitter/nvim-treesitter",
|
|
opts = { ensure_installed = { "clojure" } },
|
|
},
|
|
|
|
-- Extend auto completion
|
|
{
|
|
"hrsh7th/nvim-cmp",
|
|
optional = true,
|
|
dependencies = {
|
|
"PaterJason/cmp-conjure",
|
|
},
|
|
opts = function(_, opts)
|
|
if type(opts.sources) == "table" then
|
|
vim.list_extend(opts.sources, { name = "conjure" })
|
|
end
|
|
end,
|
|
},
|
|
|
|
-- Add s-exp mappings
|
|
{ "julienvincent/nvim-paredit", opts = {}, event = "LazyFile" },
|
|
|
|
-- Colorize the output of the log buffer
|
|
{
|
|
"m00qek/baleia.nvim",
|
|
opts = {
|
|
line_starts_at = 3,
|
|
},
|
|
config = function(_, opts)
|
|
vim.g.conjure_baleia = require("baleia").setup(opts)
|
|
|
|
vim.api.nvim_create_user_command("BaleiaColorize", function()
|
|
vim.g.conjure_baleia.once(vim.api.nvim_get_current_buf())
|
|
end, { bang = true })
|
|
|
|
vim.api.nvim_create_user_command("BaleiaLogs", vim.g.conjure_baleia.logger.show, { bang = true })
|
|
end,
|
|
},
|
|
|
|
-- Use Clojure REPL
|
|
{
|
|
"Olical/conjure",
|
|
event = "LazyFile",
|
|
config = function(_, _)
|
|
require("conjure.main").main()
|
|
end,
|
|
init = function()
|
|
-- print color codes if baleia.nvim is available
|
|
local colorize = require("lazyvim.util").has("baleia.nvim")
|
|
|
|
if colorize then
|
|
vim.g["conjure#log#strip_ansi_escape_sequences_line_limit"] = 0
|
|
else
|
|
vim.g["conjure#log#strip_ansi_escape_sequences_line_limit"] = 1
|
|
end
|
|
|
|
-- disable diagnostics in log buffer and colorize it
|
|
vim.api.nvim_create_autocmd({ "BufWinEnter" }, {
|
|
pattern = "conjure-log-*",
|
|
callback = function()
|
|
local buffer = vim.api.nvim_get_current_buf()
|
|
vim.diagnostic.enable(false, { bufnr = buffer })
|
|
|
|
if colorize and vim.g.conjure_baleia then
|
|
vim.g.conjure_baleia.automatically(buffer)
|
|
end
|
|
|
|
vim.keymap.set(
|
|
{ "n", "x" },
|
|
"[c",
|
|
"<CMD>call search('^; -\\+$', 'bw')<CR>",
|
|
{ silent = true, buffer = true, desc = "Jumps to the begining of previous evaluation output." }
|
|
)
|
|
vim.keymap.set(
|
|
{ "n", "x" },
|
|
"]c",
|
|
"<CMD>call search('^; -\\+$', 'w')<CR>",
|
|
{ silent = true, buffer = true, desc = "Jumps to the begining of next evaluation output." }
|
|
)
|
|
end,
|
|
})
|
|
|
|
-- prefer LSP for jump-to-definition and symbol-doc, and use conjure
|
|
-- alternatives with <localleader>K and <localleader>gd
|
|
vim.g["conjure#mapping#doc_word"] = "K"
|
|
vim.g["conjure#mapping#def_word"] = "gd"
|
|
end,
|
|
},
|
|
}
|