I have the folke/lua-dev package setup to make my Lua config editing more pleasant, however, I only want it to activate when the actual file being edited is inside of ~/.config/nvim.
Unfortunately, inside of custom.plugins.lspconfig -> M.setup_lsp -> lsp_installer.on_server_ready() we can't use vim.fn.expand("%:p") to get the path to the buffer being edited.
nogweii @ lua-dev.nvim posted about exactly how to apply this to nvim generally:
So if we can't get access to the current file inside of custom.plugins.lspconfig, then where would we insert something like this?
For reference I'm trying to do:
local M = {}
M.setup_lsp = function(attach, capabilities)
local lsp_installer = require "nvim-lsp-installer"
lsp_installer.on_server_ready(function(server)
local opts = {
on_attach = attach,
capabilities = capabilities,
flags = {
debounce_text_changes = 150,
},
settings = {},
}
local cfgpath = vim.fn.resolve(vim.fn.stdpath("config"))
-- Problem is here...
local bufpath = vim.fn.expand("%:p")
-- `expand("%:p")` comes back empty...
if server.name == "sumneko_lua" then
if string.sub(bufpath, 1, string.len(cfgpath)) == cfgpath then
opts.settings = require("lua-dev").setup().settings
end
end
server:setup(opts)
vim.cmd [[ do User LspAttachBuffers ]]
end)
end
return M
Thanks so much for taking the time to read though this!
Describe the bug
I have the
folke/lua-dev
package setup to make my Lua config editing more pleasant, however, I only want it to activate when the actual file being edited is inside of ~/.config/nvim.Unfortunately, inside of
custom.plugins.lspconfig
->M.setup_lsp
->lsp_installer.on_server_ready()
we can't usevim.fn.expand("%:p")
to get the path to the buffer being edited.nogweii @ lua-dev.nvim posted about exactly how to apply this to nvim generally:
https://github.com/folke/lua-dev.nvim/issues/12#issuecomment-1000062991
So if we can't get access to the current file inside of
custom.plugins.lspconfig
, then where would we insert something like this?For reference I'm trying to do:
Thanks so much for taking the time to read though this!