Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions after/lsp/emmet_language_server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---@type vim.lsp.Config
return {
init_options = {
includeLanguages = {
templ = "html",
},
},
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 4 additions & 0 deletions after/lsp/sourcekit.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---@type vim.lsp.Config | { settings?: lsp.sourcekit }
return {
filetypes = { "swift" },
}
8 changes: 8 additions & 0 deletions after/lsp/tailwindcss.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---@type vim.lsp.Config | { settings?: lsp.tailwindcss }
return {
settings = {
tailwindCSS = {
emmetCompletions = true,
},
},
}
File renamed without changes.
File renamed without changes.
84 changes: 64 additions & 20 deletions lua/autocmds.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
---@class Autocmds
---@field setup fun(self: Autocmds)
---@field lsp_setup fun(self: Autocmds)
local Autocmds = {}

function Autocmds:lsp_setup()
local events = { "BufEnter", "LspAttach" }

vim.api.nvim_create_autocmd(events, {
desc = "Use LSP folding if available",
group = vim.api.nvim_create_augroup("lsp-folding", { clear = true }),
callback = function(args)
local has_lsp_folding = vim.iter(vim.lsp.get_clients({ bufnr = args.buf })):any(
function(client) return client:supports_method("textDocument/foldingRange") end
)
local foldexpr = has_lsp_folding and "v:lua.vim.lsp.foldexpr()"
or "v:lua.vim.treesitter.foldexpr()"

vim
.iter(vim.fn.win_findbuf(args.buf))
:filter(function(winid) return vim.wo[winid].foldexpr ~= foldexpr end)
:each(function(winid)
vim.wo[winid].foldexpr = foldexpr
vim.api.nvim_win_call(winid, function() vim.cmd("normal! zx") end)
end)
end,
})

vim.api.nvim_create_autocmd(events, {
desc = "Don't use LSP document colors if available",
group = vim.api.nvim_create_augroup("lsp-document-colors", { clear = true }),
callback = function(args)
local has_document_color = vim.iter(vim.lsp.get_clients({ bufnr = args.buf })):any(
function(client) return client:supports_method("textDocument/documentColor") end
)
if has_document_color then
vim.lsp.document_color.enable(false, { bufnr = args.buf }, { style = "virtual" })
end
end,
})

vim.api.nvim_create_autocmd(events, {
desc = "Enable inlay hints",
group = vim.api.nvim_create_augroup("lsp-inlay-hints", { clear = true }),
callback = function(args)
local has_inlay_hints = vim.iter(vim.lsp.get_clients({ bufnr = args.buf })):any(
function(client) return client:supports_method("textDocument/inlayHint") end
)
if has_inlay_hints then vim.lsp.inlay_hint.enable(true, { bufnr = args.buf }) end
end,
})

vim.api.nvim_create_autocmd(events, {
desc = "Enable code lens",
group = vim.api.nvim_create_augroup("lsp-code-lens", { clear = true }),
callback = function(args)
local has_code_lens = vim.iter(vim.lsp.get_clients({ bufnr = args.buf })):any(
function(client) return client:supports_method("textDocument/codeLens") end
)
local should_enable =
not vim.tbl_contains(require("nikero.config").hide_code_lens_ft, vim.bo[args.buf].filetype)
if has_code_lens then vim.lsp.codelens.enable(should_enable, { bufnr = args.buf }) end
end,
})
end

function Autocmds:setup()
-- Custom "User File" Event
--
Expand Down Expand Up @@ -67,26 +129,6 @@ function Autocmds:setup()
callback = function() vim.hl.on_yank() end,
})

vim.api.nvim_create_autocmd({ "BufEnter", "LspAttach" }, {
desc = "Use LSP folding if available",
group = vim.api.nvim_create_augroup("lsp-folding", { clear = true }),
callback = function(args)
local has_lsp_folding = vim.iter(vim.lsp.get_clients({ bufnr = args.buf })):any(
function(client) return client:supports_method("textDocument/foldingRange") end
)
local foldexpr = has_lsp_folding and "v:lua.vim.lsp.foldexpr()"
or "v:lua.vim.treesitter.foldexpr()"

vim
.iter(vim.fn.win_findbuf(args.buf))
:filter(function(winid) return vim.wo[winid].foldexpr ~= foldexpr end)
:each(function(winid)
vim.wo[winid].foldexpr = foldexpr
vim.api.nvim_win_call(winid, function() vim.cmd("normal! zx") end)
end)
end,
})

vim.api.nvim_create_autocmd("VimResized", {
desc = "Resize splits if window got resized",
group = vim.api.nvim_create_augroup("resize-splits", { clear = true }),
Expand Down Expand Up @@ -128,6 +170,8 @@ function Autocmds:setup()
group = vim.api.nvim_create_augroup("terminal-progress-bar", { clear = true }),
callback = function(args) require("nikero.progress_bar"):on_lsp_progress(args) end,
})

self:lsp_setup()
end

return Autocmds
1 change: 1 addition & 0 deletions lua/nikero/config.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---@class Config
local Config = {
transparency = false,
hide_code_lens_ft = { "lua" },
}

return Config
19 changes: 3 additions & 16 deletions lua/plugins/language/support.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,14 @@ return {

vim
.iter(extra_filetypes)
:enumerate()
:filter(function(server) return not not vim.lsp.config[server] end)
:each(function(server)
:each(function(server, extra)
local config = vim.lsp.config[server] or {}
local filetypes = vim.deepcopy(config.filetypes or {})
vim.lsp.config(server, {
filetypes = vim.list.unique(
vim.tbl_extend("force", config.filetypes or {}, extra_filetypes[server])
),
filetypes = vim.list.unique(vim.list_extend(filetypes, extra)),
})
end)

vim.lsp.config("*", {
---@param client vim.lsp.Client The LSP client details when attaching
---@param buffer integer The buffer that the LSP client is attaching to
on_attach = function(client, buffer)
if client:supports_method("textDocument/codeLens", buffer) then
vim.lsp.codelens.enable(true, { bufnr = buffer })
end
vim.lsp.inlay_hint.enable()
end,
})
end,
},
},
Expand Down
3 changes: 1 addition & 2 deletions lua/plugins/quickfix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ return {

local should_close = vim.tbl_count(
vim
.iter(results)
:enumerate()
.iter(ipairs(results))
:filter(
function(pos_id, result)
return result.status ~= "failed" and tree:get_key(pos_id)
Expand Down
Loading