diff --git a/.config/nvim/lazyvim.json b/.config/nvim/lazyvim.json index 143ce4d6..070aa838 100644 --- a/.config/nvim/lazyvim.json +++ b/.config/nvim/lazyvim.json @@ -26,7 +26,10 @@ "plugins.extras.alpha", "plugins.extras.codeium", "plugins.extras.git", - "plugins.extras.github" + "plugins.extras.github", + "plugins.extras.hints", + "plugins.extras.rest-client", + "plugins.extras.typescript" ], "news": { "NEWS.md": "2123" diff --git a/.config/nvim/lua/plugins/extras/fold.lua b/.config/nvim/lua/plugins/extras/fold.lua new file mode 100644 index 00000000..5a684bf7 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/fold.lua @@ -0,0 +1,116 @@ +return { + { + "lewis6991/gitsigns.nvim", + optional = true, + opts = { + signs = { + add = { text = "┃" }, + change = { text = "┃" }, + delete = { text = "󱈸" }, + topdelete = { text = "󱈸" }, + changedelete = { text = "┃" }, + untracked = { text = "┇" }, + }, + signcolumn = true, + numhl = true, + }, + }, + { + "neovim/nvim-lspconfig", + optional = true, + init = function() + local keys = require("lazyvim.plugins.lsp.keymaps").get() + keys[#keys + 1] = { "K", false } + end, + }, + { -- better statuscolumn + "luukvbaal/statuscol.nvim", + event = { "BufRead", "BufNewFile" }, + opts = function() + local builtin = require("statuscol.builtin") + return { + ft_ignore = { "neo-tree", "neo-tree-popup", "alpha", "lazy", "mason" }, + segments = { + { text = { builtin.lnumfunc }, click = "v:lua.ScLa" }, + { + sign = { name = { "Diagnostic*" }, text = { ".*" }, maxwidth = 1, colwidth = 1, auto = true }, + click = "v:lua.ScSa", + }, + { text = { builtin.foldfunc, " " }, click = "v:lua.ScFa" }, + }, + } + end, + init = function() end, + config = function(_, opts) + require("statuscol").setup(opts) + end, + }, + { -- better fold + "kevinhwang91/nvim-ufo", + event = { "BufRead", "BufNewFile" }, + dependencies = { "kevinhwang91/promise-async" }, + init = function() + vim.o.foldcolumn = "1" + vim.o.foldlevel = 99 + vim.o.foldlevelstart = 99 + vim.o.foldenable = true + end, + opts = function() + local handler = function(virtText, lnum, endLnum, width, truncate) + local newVirtText = {} + local suffix = (" ... 󰁂 %d "):format(endLnum - lnum) + local sufWidth = vim.fn.strdisplaywidth(suffix) + local targetWidth = width - sufWidth + local curWidth = 0 + for _, chunk in ipairs(virtText) do + local chunkText = chunk[1] + local chunkWidth = vim.fn.strdisplaywidth(chunkText) + if targetWidth > curWidth + chunkWidth then + table.insert(newVirtText, chunk) + else + chunkText = truncate(chunkText, targetWidth - curWidth) + local hlGroup = chunk[2] + table.insert(newVirtText, { chunkText, hlGroup }) + chunkWidth = vim.fn.strdisplaywidth(chunkText) + -- str width returned from truncate() may less than 2nd argument, need padding + if curWidth + chunkWidth < targetWidth then + suffix = suffix .. (" "):rep(targetWidth - curWidth - chunkWidth) + end + break + end + curWidth = curWidth + chunkWidth + end + table.insert(newVirtText, { suffix, "MoreMsg" }) + return newVirtText + end + + return { + fold_virt_text_handler = handler, + provider_selector = function() + return { "treesitter", "indent" } + end, + open_fold_hl_timeout = 400, + close_fold_kinds = { "imports", "comment" }, + preview = { + win_config = { border = { "", "─", "", "", "", "─", "", "" }, winblend = 0 }, + mappings = { + scrollU = "", + scrollD = "", + jumpTop = "[", + jumpBot = "]", + }, + }, + } + end, + config = function(_, opts) + require("ufo").setup(opts) + + local map = require("lazyvim.util").safe_keymap_set + map("n", "K", function() + if not require("ufo").peekFoldedLinesUnderCursor() then + vim.lsp.buf.hover() + end + end, { desc = "Peek folded lines under cursor or hover" }) + end, + }, +} diff --git a/.config/nvim/lua/plugins/extras/hints.lua b/.config/nvim/lua/plugins/extras/hints.lua new file mode 100644 index 00000000..1e986307 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/hints.lua @@ -0,0 +1,26 @@ +return { + { + "lvimuser/lsp-inlayhints.nvim", + init = function() + vim.api.nvim_create_autocmd("LspAttach", { + group = vim.api.nvim_create_augroup("LspAttach_inlayhints", {}), + callback = function(args) + if not (args.data and args.data.client_id) then + return + end + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client.server_capabilities.inlayHintProvider then + local inlayhints = require("lsp-inlayhints") + inlayhints.on_attach(client, args.buf) + end + end, + }) + end, + opts = {}, + }, + { + "simrat39/rust-tools.nvim", + optional = true, + opts = { tools = { inlay_hints = { auto = false } } }, + }, +} diff --git a/.config/nvim/lua/plugins/extras/rest-client.lua b/.config/nvim/lua/plugins/extras/rest-client.lua new file mode 100644 index 00000000..c7519163 --- /dev/null +++ b/.config/nvim/lua/plugins/extras/rest-client.lua @@ -0,0 +1,70 @@ +return { + { + "rest-nvim/rest.nvim", + dependencies = { + { + "gennaro-tedesco/nvim-jqx", + ft = { "json", "yaml" }, + }, + }, + ft = { "http" }, + opts = { + -- Open request results in a horizontal split + result_split_horizontal = true, + -- Keep the http file buffer above|left when split horizontal|vertical + result_split_in_place = false, + -- Skip SSL verification, useful for unknown certificates + skip_ssl_verification = false, + -- Encode URL before making request + encode_url = true, + -- Highlight request on run + highlight = { + enabled = true, + timeout = 150, + }, + result = { + -- toggle showing URL, HTTP info, headers at top the of result window + show_url = true, + show_http_info = true, + show_headers = true, + -- executables or functions for formatting response body [optional] + -- set them to false if you want to disable them + formatters = { + json = "jq", + html = function(body) + return vim.fn.system({ "tidy", "-i", "-q", "-" }, body) + end, + }, + }, + -- Jump to request line on run + jump_to_request = false, + env_file = ".env", + custom_dynamic_variables = {}, + yank_dry_run = true, + }, + keys = { + { + "thp", + function() + require("rest-nvim").run(true) + end, + desc = "Preview Request", + }, + { + "thr", + function() + require("rest-nvim").run() + end, + desc = "Run Request", + }, + }, + }, + { + "folke/which-key.nvim", + opts = { + defaults = { + ["th"] = { name = "+http" }, + }, + }, + }, +} diff --git a/.config/nvim/lua/plugins/extras/typescript.lua b/.config/nvim/lua/plugins/extras/typescript.lua new file mode 100644 index 00000000..c3ceac3b --- /dev/null +++ b/.config/nvim/lua/plugins/extras/typescript.lua @@ -0,0 +1,72 @@ +return { + { + "neovim/nvim-lspconfig", + opts = { + -- make sure mason installs the server + servers = { + ---@type lspconfig.options.tsserver + tsserver = { + init_options = { + preferences = { + disableSuggestions = true, + }, + }, + keys = { + { + "co", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.organizeImports.ts" }, + diagnostics = {}, + }, + }) + end, + desc = "Organize Imports", + }, + }, + settings = { + typescript = { + format = { + indentSize = vim.o.shiftwidth, + convertTabsToSpaces = vim.o.expandtab, + tabSize = vim.o.tabstop, + }, + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = false, + includeInlayVariableTypeHintsWhenTypeMatchesName = false, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + javascript = { + format = { + indentSize = vim.o.shiftwidth, + convertTabsToSpaces = vim.o.expandtab, + tabSize = vim.o.tabstop, + }, + inlayHints = { + includeInlayParameterNameHints = "all", + includeInlayParameterNameHintsWhenArgumentMatchesName = false, + includeInlayFunctionParameterTypeHints = true, + includeInlayVariableTypeHints = false, + includeInlayVariableTypeHintsWhenTypeMatchesName = false, + includeInlayPropertyDeclarationTypeHints = true, + includeInlayFunctionLikeReturnTypeHints = true, + includeInlayEnumMemberValueHints = true, + }, + }, + completions = { + completeFunctionCalls = true, + }, + }, + }, + }, + }, + }, +}