From 35d6c20abdbdd00f5895519440e3e4958c4e0c38 Mon Sep 17 00:00:00 2001 From: Taken Date: Tue, 26 Aug 2025 11:46:42 +0200 Subject: [PATCH] Updated config --- .emmyrc.json | 19 ++++++-- lua/taken/core/cmd.lua | 1 + lua/taken/core/remaps.lua | 1 + lua/taken/lazy.lua | 2 +- lua/taken/plugins/alpha.lua | 2 + lua/taken/plugins/conform.lua | 9 +++- lua/taken/plugins/harpoon.lua | 1 + lua/taken/plugins/indent-blankline.lua | 34 ++++---------- lua/taken/plugins/lsp/lspconfig.lua | 65 ++++++++++++++------------ lua/taken/plugins/lsp/tailwind.lua | 1 + lua/taken/plugins/notify.lua | 1 + lua/taken/plugins/nvim-cmp.lua | 1 + lua/taken/plugins/snacks.lua | 2 +- lua/taken/types.lua | 4 +- lua/taken/utils/on_attach.lua | 9 ++++ lua/taken/utils/themefuncs.lua | 2 +- lua/taken/utils/themes.lua | 1 + 17 files changed, 88 insertions(+), 67 deletions(-) diff --git a/.emmyrc.json b/.emmyrc.json index f379057..ea30de7 100644 --- a/.emmyrc.json +++ b/.emmyrc.json @@ -1,20 +1,29 @@ { "$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json", + "diagnostics": { + "disable": [ + "undefined-field", + "undefined-field" + ] + }, "runtime": { - "version": "LuaJIT", "requirePattern": [ "lua/?.lua", "lua/?/init.lua", "?/lua/?.lua", "?/lua/?/init.lua" - ] + ], + "version": "LuaJIT" }, "workspace": { + "ignoreGlobs": [ + "**/*_spec.lua" + ], "library": [ "$VIMRUNTIME", "$HOME/.local/share/nvim/lazy/luvit-meta", - "$HOME/.local/share/nvim/lazy/lazy.nvim" - ], - "ignoreGlobs": ["**/*_spec.lua"] + "$HOME/.local/share/nvim/lazy/lazy.nvim", + "$HOME/.local/share/nvim/lazy" + ] } } diff --git a/lua/taken/core/cmd.lua b/lua/taken/core/cmd.lua index 82183de..dd5c51d 100644 --- a/lua/taken/core/cmd.lua +++ b/lua/taken/core/cmd.lua @@ -15,6 +15,7 @@ cmd("SetTheme", function(arg) local allthemes = themefuncs.get_all_themes() if vim.tbl_contains(allthemes, themeselected) then + ---@diagnostic disable-next-line: param-type-not-match themefuncs.change_theme(themeselected) else vim.notify("Invalid selection", vim.log.levels.ERROR) diff --git a/lua/taken/core/remaps.lua b/lua/taken/core/remaps.lua index 069a7e6..f41e4f9 100644 --- a/lua/taken/core/remaps.lua +++ b/lua/taken/core/remaps.lua @@ -1,3 +1,4 @@ +--- @type Maps local M = { v = { ["J"] = { ":m '>+1gv=gv" }, diff --git a/lua/taken/lazy.lua b/lua/taken/lazy.lua index 6004652..2d5f99e 100644 --- a/lua/taken/lazy.lua +++ b/lua/taken/lazy.lua @@ -13,12 +13,12 @@ vim.opt.rtp:prepend(lazypath) local lazy = require("lazy") ---- @type LazyPluginSpec[] local plugins = { { import = "taken.plugins" }, { import = "taken.plugins.lsp" }, } +---@diagnostic disable-next-line: missing-fields --- @type LazyConfig local opts = { checker = { diff --git a/lua/taken/plugins/alpha.lua b/lua/taken/plugins/alpha.lua index 1c0fe63..fb77237 100644 --- a/lua/taken/plugins/alpha.lua +++ b/lua/taken/plugins/alpha.lua @@ -57,7 +57,9 @@ return { local line3 = " " .. version local line1_width = vim.fn.strdisplaywidth(line1) + ---@diagnostic disable-next-line: param-type-not-match local line2Padded = string.rep(" ", (line1_width - vim.fn.strdisplaywidth(line2)) / 2) .. line2 + ---@diagnostic disable-next-line: param-type-not-match local line3Padded = string.rep(" ", (line1_width - vim.fn.strdisplaywidth(line3)) / 2) .. line3 dashboard.section.footer.val = { diff --git a/lua/taken/plugins/conform.lua b/lua/taken/plugins/conform.lua index 57930bf..b901e24 100644 --- a/lua/taken/plugins/conform.lua +++ b/lua/taken/plugins/conform.lua @@ -4,9 +4,11 @@ return { event = { "BufReadPre", "BufNewFile" }, config = function() local function checkPrettierConfig() - local prettier_config = vim.fn.glob(".prettierrc*", false, 1) + local prettier_config = vim.fn.glob(".prettierrc*", false, true) if prettier_config[1] == nil then return false + else + return true end end @@ -40,6 +42,11 @@ return { local range = nil if args.count ~= -1 then local end_line = vim.api.nvim_buf_get_lines(0, args.line2 - 1, args.line2, true)[1] + + if end_line == nil then + return + end + range = { start = { args.line1, 0 }, ["end"] = { args.line2, end_line:len() }, diff --git a/lua/taken/plugins/harpoon.lua b/lua/taken/plugins/harpoon.lua index a2fa905..898c3f5 100644 --- a/lua/taken/plugins/harpoon.lua +++ b/lua/taken/plugins/harpoon.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field --- @type LazyPluginSpec return { "ThePrimeagen/harpoon", diff --git a/lua/taken/plugins/indent-blankline.lua b/lua/taken/plugins/indent-blankline.lua index 730fecb..6402ea1 100644 --- a/lua/taken/plugins/indent-blankline.lua +++ b/lua/taken/plugins/indent-blankline.lua @@ -3,7 +3,6 @@ return { "lukas-reineke/indent-blankline.nvim", main = "ibl", event = { "BufReadPre", "BufNewFile" }, - enabled = false, config = function() local blankline = require("ibl") local hooks = require("ibl.hooks") @@ -12,38 +11,21 @@ return { vim.opt.listchars:append("space:⋅") local highlight = { - "RainbowDelimiterRed", - "RainbowDelimiterYellow", - "RainbowDelimiterBlue", - "RainbowDelimiterOrange", - "RainbowDelimiterGreen", - "RainbowDelimiterViolet", - "RainbowDelimiterCyan", + "CursorColumn", + "Whitespace", } - hooks.register(hooks.type.HIGHLIGHT_SETUP, function() - vim.api.nvim_set_hl(0, "RainbowDelimiterRed", { fg = "#E06C75" }) - vim.api.nvim_set_hl(0, "RainbowDelimiterYellow", { fg = "#E5C07B" }) - vim.api.nvim_set_hl(0, "RainbowDelimiterBlue", { fg = "#61AFEF" }) - vim.api.nvim_set_hl(0, "RainbowDelimiterOrange", { fg = "#D19A66" }) - vim.api.nvim_set_hl(0, "RainbowDelimiterGreen", { fg = "#98C379" }) - vim.api.nvim_set_hl(0, "RainbowDelimiterViolet", { fg = "#C678DD" }) - vim.api.nvim_set_hl(0, "RainbowDelimiterCyan", { fg = "#56B6C2" }) - end) - - vim.g.rainbow_delimiters = { highlight = highlight } - hooks.register(hooks.type.SCOPE_HIGHLIGHT, hooks.builtin.scope_highlight_from_extmark) blankline.setup({ - indent = { - char = "│", - highlight = highlight, - }, scope = { - enabled = true, + enabled = false, char = "│", - highlight = highlight, show_exact_scope = true, }, + indent = { highlight = highlight, char = "" }, + whitespace = { + highlight = highlight, + remove_blankline_trail = false, + }, }) end, } diff --git a/lua/taken/plugins/lsp/lspconfig.lua b/lua/taken/plugins/lsp/lspconfig.lua index ae2268b..3e5701b 100644 --- a/lua/taken/plugins/lsp/lspconfig.lua +++ b/lua/taken/plugins/lsp/lspconfig.lua @@ -11,15 +11,16 @@ return { }, event = { "BufReadPre", "BufNewFile" }, config = function() + local blink = require("blink.cmp") + -- local cmp_nvim_lsp = require("cmp_nvim_lsp") local tserrortranslator = require("ts-error-translator") local on_attach = require("taken.utils.on_attach") local get_python_path = require("taken.utils.lsp").get_python_path - -- local cmp_nvim_lsp = require("cmp_nvim_lsp") -- local capabilities = cmp_nvim_lsp.default_capabilities() - local blink = require("blink.cmp") - local capabilities = blink.get_lsp_capabilities() + local default_capabilities = vim.lsp.protocol.make_client_capabilities() + local capabilities = vim.tbl_deep_extend("force", default_capabilities, blink.get_lsp_capabilities({}, false)) vim.diagnostic.config({ signs = { @@ -41,41 +42,45 @@ return { "eslint", "cspell_ls", "kulala_ls", - -- "emmylua_ls", + "emmylua_ls", } vim.lsp.config("*", { capabilities = capabilities, + ---@diagnostic disable-next-line: assign-type-mismatch on_attach = on_attach, }) + --- @class LspConfigs + --- @field lsp string + --- @field config vim.lsp.Config local lsps = { - { - lsp = "lua_ls", - config = { - capabilities = capabilities, - on_attach = on_attach, - settings = { - Lua = { - hint = { - enable = true, - }, - runtime = { - version = "LuaJIT", - }, - diagnostics = { - globals = { "vim" }, - }, - completion = { - callSnippet = "Replace", - }, - format = { - enable = false, - }, - }, - }, - }, - }, + -- { + -- lsp = "lua_ls", + -- config = { + -- capabilities = capabilities, + -- on_attach = on_attach, + -- settings = { + -- Lua = { + -- hint = { + -- enable = true, + -- }, + -- runtime = { + -- version = "LuaJIT", + -- }, + -- diagnostics = { + -- globals = { "vim" }, + -- }, + -- completion = { + -- callSnippet = "Replace", + -- }, + -- format = { + -- enable = false, + -- }, + -- }, + -- }, + -- }, + -- }, { lsp = "pyright", config = { diff --git a/lua/taken/plugins/lsp/tailwind.lua b/lua/taken/plugins/lsp/tailwind.lua index d0b5aec..719ae9a 100644 --- a/lua/taken/plugins/lsp/tailwind.lua +++ b/lua/taken/plugins/lsp/tailwind.lua @@ -13,6 +13,7 @@ return { config = function() local on_attach = require("taken.utils.on_attach") + ---@diagnostic disable-next-line: missing-fields, param-type-not-match, missing-parameter require("tailwind-tools").setup({ server = { on_attach = on_attach, diff --git a/lua/taken/plugins/notify.lua b/lua/taken/plugins/notify.lua index ff4a337..d319f3f 100644 --- a/lua/taken/plugins/notify.lua +++ b/lua/taken/plugins/notify.lua @@ -11,6 +11,7 @@ return { timeout = 2500, }) + ---@diagnostic disable-next-line: assign-type-mismatch vim.notify = notify end, } diff --git a/lua/taken/plugins/nvim-cmp.lua b/lua/taken/plugins/nvim-cmp.lua index f526c50..a83058b 100644 --- a/lua/taken/plugins/nvim-cmp.lua +++ b/lua/taken/plugins/nvim-cmp.lua @@ -1,3 +1,4 @@ +---@diagnostic disable: undefined-field --- @type LazyPluginSpec return { "hrsh7th/nvim-cmp", diff --git a/lua/taken/plugins/snacks.lua b/lua/taken/plugins/snacks.lua index 071ada8..e0f7827 100644 --- a/lua/taken/plugins/snacks.lua +++ b/lua/taken/plugins/snacks.lua @@ -20,7 +20,7 @@ return { Snacks.notifier.show_history() end, { desc = "Show notification history" }) vim.keymap.set("n", "oh", function() - snacks.notifier.show_history() + Snacks.notifier.show_history() end, { desc = "Show notification history" }) end, } diff --git a/lua/taken/types.lua b/lua/taken/types.lua index 73754d0..5135b63 100644 --- a/lua/taken/types.lua +++ b/lua/taken/types.lua @@ -1,7 +1,7 @@ -- maps --- @class MappingOpts ---- @field [1] string ---- @field desc string +--- @field [1] string | function +--- @field desc string? --- @alias Mapping table diff --git a/lua/taken/utils/on_attach.lua b/lua/taken/utils/on_attach.lua index cd392f8..5345b7a 100644 --- a/lua/taken/utils/on_attach.lua +++ b/lua/taken/utils/on_attach.lua @@ -1,10 +1,14 @@ --- @param client vim.lsp.Client --- @param bufnr number local on_attach = function(client, bufnr) + --- @param desc string? + --- @return vim.keymap.set.Opts? local function opts(desc) if desc then + ---@diagnostic disable-next-line: return-type-mismatch return { silent = true, buffer = bufnr, desc = desc } else + ---@diagnostic disable-next-line: return-type-mismatch return { silent = true, buffer = bufnr } end end @@ -31,6 +35,7 @@ local on_attach = function(client, bufnr) end, opts("Get code actions")) vim.keymap.set("n", "vr", function() return ":IncRename " .. vim.fn.expand("") + ---@diagnostic disable-next-line: param-type-not-match end, { expr = true, silent = true, buffer = bufnr, desc = "Rename symbol" }) vim.keymap.set("n", "vn", function() vim.lsp.buf.rename() @@ -41,6 +46,10 @@ local on_attach = function(client, bufnr) return end + if client.server_capabilities == nil then + return + end + if client.server_capabilities.inlayHintProvider then local current_state = vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }) vim.lsp.inlay_hint.enable(not current_state, { bufnr = bufnr }) diff --git a/lua/taken/utils/themefuncs.lua b/lua/taken/utils/themefuncs.lua index 4501834..ec7fe8c 100644 --- a/lua/taken/utils/themefuncs.lua +++ b/lua/taken/utils/themefuncs.lua @@ -8,7 +8,7 @@ local get_all_themes = function() local colors = vim.fn.globpath(vim.o.rtp, "colors/*", true, true) local dataDir = vim.fn.stdpath("data") - ---@diagnostic disable-next-line: param-type-mismatch + ---@diagnostic disable-next-line: param-type-not-match local newpath = string.gsub(dataDir, "%-", "%%-") local themes = {} diff --git a/lua/taken/utils/themes.lua b/lua/taken/utils/themes.lua index 64c3170..588506a 100644 --- a/lua/taken/utils/themes.lua +++ b/lua/taken/utils/themes.lua @@ -43,6 +43,7 @@ function M.themeselector(opts) if selection == nil then vim.notify("Error while selecting theme", vim.log.levels.ERROR) end + ---@diagnostic disable-next-line: need-check-nil vim.cmd("colorscheme " .. selection.value) end, })