Skip to content

Commit

Permalink
chore(nivm): up
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 14, 2024
1 parent d02078c commit 700d804
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 71 deletions.
5 changes: 4 additions & 1 deletion .config/nvim/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
## Issues

- gf in terminal does not focus file (opens in background)
- snacks notifications not working (noice issue?)
- syntax groups flash when loading files
- neotest output does not auto-scroll in edgy
- add search results to scrollbar
Expand All @@ -16,9 +15,12 @@
- https://github.com/folke/todo-comments.nvim
- https://github.com/nvim-treesitter/nvim-treesitter-textobjects
- https://github.com/mfussenegger/nvim-lint
- https://github.com/dmmulroy/ts-error-translator.nvim

## Misc (unordered)

- emmet-like plugin
- switch from cmp to blink
- dap firefox https://github.com/firefox-devtools/vscode-firefox-debug
- add recording macro to statusline
- lualine branch supports git worktree
Expand All @@ -27,6 +29,7 @@

## Links

- https://github.com/MariaSolOs/dotfiles
- https://github.com/folke/dot
- https://gist.github.com/rsms/fb463396c95ad8d9efa338a8050a01dc
- https://github.com/ssgabrieldev/tools/blob/d27bd8466dcd7852de02a9733cd698f77158bf28/nvim/lua/plugins/dap.lua#L178
16 changes: 8 additions & 8 deletions .config/nvim/lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"conform.nvim": { "branch": "master", "commit": "8c354323201d04530727d8bdcc4669791ee082ef" },
"conform.nvim": { "branch": "master", "commit": "023f795dbcf32d4351b6a9ed2e613d471b5bb812" },
"copilot-cmp": { "branch": "master", "commit": "b6e5286b3d74b04256d0a7e3bd2908eabec34b44" },
"copilot.lua": { "branch": "master", "commit": "f8d8d872bb319f640d5177dad5fbf01f7a16d7d0" },
"dressing.nvim": { "branch": "master", "commit": "43b8f74e0b1e3f41e51f640f8efa3bcd401cea0d" },
"dressing.nvim": { "branch": "master", "commit": "fc78a3ca96f4db9f8893bb7e2fd9823e0780451b" },
"edgy.nvim": { "branch": "main", "commit": "7e8dedc39abebe40c289b8012cc89b11c69aa7a0" },
"flash.nvim": { "branch": "main", "commit": "34c7be146a91fec3555c33fe89c7d643f6ef5cf1" },
"friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" },
"gitsigns.nvim": { "branch": "main", "commit": "4daf7022f1481edf1e8fb9947df13bb07c18e89a" },
"gitsigns.nvim": { "branch": "main", "commit": "ac5aba6dce8c06ea22bea2c9016f51a2dbf90dc7" },
"indent-blankline.nvim": { "branch": "master", "commit": "7871a88056f7144defca9c931e311a3134c5d509" },
"lazy.nvim": { "branch": "main", "commit": "7967abe55752aa90532e6bb4bd4663fe27a264cb" },
"lualine.nvim": { "branch": "master", "commit": "2a5bae925481f999263d6f5ed8361baef8df4f83" },
Expand All @@ -22,22 +22,22 @@
"neotest": { "branch": "master", "commit": "6d3d22cdad49999ef774ebe1bc250a4994038964" },
"neotest-elixir": { "branch": "master", "commit": "c5067bcc3ec6a0bba7b5694fa15aeb17f16aeb3c" },
"neotest-vitest": { "branch": "main", "commit": "9e30dca989a2287cf3fde86b3e138ea7fa4de935" },
"noice.nvim": { "branch": "main", "commit": "2087bbf8cd64482b47fb5f33b5e0eabf329ab14b" },
"noice.nvim": { "branch": "main", "commit": "ca2e3fea9fb080dcb79d9129d73dac631294fe79" },
"nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" },
"nvim-cmp": { "branch": "main", "commit": "f17d9b4394027ff4442b298398dfcaab97e40c4f" },
"nvim-dap": { "branch": "master", "commit": "8517126e9323e346f6a99b3b594c5a940b914dcd" },
"nvim-dap": { "branch": "master", "commit": "6bf4de67dbe90271608e1c81797e5edc79ec6335" },
"nvim-dap-ui": { "branch": "master", "commit": "ffa89839f97bad360e78428d5c740fdad9a0ff02" },
"nvim-dap-virtual-text": { "branch": "master", "commit": "76d80c3d171224315b61c006502a1e30c213a9ab" },
"nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" },
"nvim-lspconfig": { "branch": "master", "commit": "4cb925e96288a71409a86c84fd97f4434a95453e" },
"nvim-lspconfig": { "branch": "master", "commit": "d2d153a179ed59aa7134d7ebdf4d7dcb156efa22" },
"nvim-nio": { "branch": "master", "commit": "a428f309119086dc78dd4b19306d2d67be884eee" },
"nvim-scrollbar": { "branch": "main", "commit": "6994eb9f73d5fdc36ee2c8717940e8c853e51a49" },
"nvim-snippets": { "branch": "main", "commit": "56b4052f71220144689caaa2e5b66222ba5661eb" },
"nvim-treesitter": { "branch": "master", "commit": "bb06afa3f1111780932b3c5493ad65473ce85f9d" },
"nvim-treesitter": { "branch": "master", "commit": "6389ceb1758b8f62a15194e3b790e33268304cb8" },
"nvim-treesitter-context": { "branch": "master", "commit": "158377d700596367a91ea41818f76abdbf75a232" },
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"snacks.nvim": { "branch": "main", "commit": "bc0cf370915ac4e8d5b1bd8188b5091a4a0ee22c" },
"snacks.nvim": { "branch": "main", "commit": "14c787540828946126f2acb5e542dc57956c2711" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "85922dde3767e01d42a08e750a773effbffaea3e" },
"trouble.nvim": { "branch": "main", "commit": "3dc00c0447c016cd43e03054c3d49436a1f2076d" },
Expand Down
2 changes: 1 addition & 1 deletion .config/nvim/lua/util/keymaps.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function M.get()
{ "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" },
{ "\\", function() return vim.lsp.buf.hover() end, desc = "Hover" },
{ "gK", function() return vim.lsp.buf.signature_help() end, desc = "Signature Help", has = "signatureHelp" },
{ "<c-k>", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" },
{ "<c-k>", function () vim.lsp.buf.signature_help() end, mode = "i", desc = "Signature Help", has = "signatureHelp" },
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
{ "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" },
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
Expand Down
91 changes: 30 additions & 61 deletions .config/nvim/lua/util/ui.lua
Original file line number Diff line number Diff line change
@@ -1,49 +1,47 @@
---@class util.ui
local M = {}

M.skip_foldexpr = {} ---@type table<number,boolean>
local skip_check = assert(vim.uv.new_check())

-- optimized treesitter foldexpr for Neovim >= 0.10.0
function M.foldexpr()
local buf = vim.api.nvim_get_current_buf()

-- no highlight, no foldexpr
if not vim.b[buf].ts_highlight then
return "0"
if vim.b[buf].ts_folds == nil then
-- as long as we don't have a filetype, don't bother
-- checking if treesitter is available (it won't)
if vim.bo[buf].filetype == "" then
return "0"
end
vim.b[buf].ts_folds = pcall(vim.treesitter.get_parser, buf)
end
return vim.b[buf].ts_folds and vim.treesitter.foldexpr() or "0"
end

-- still in the same tick and no parser
if M.skip_foldexpr[buf] then
return "0"
-- Based on https://github.com/Wansmer/nvim-config/blob/main/lua/modules/foldtext.lua
-- Which is based on https://www.reddit.com/r/neovim/comments/16sqyjz/finally_we_can_have_highlighted_folds/
function M.foldtext()
local result = M.parse_line(vim.v.foldstart)
if not result then
return vim.fn.foldtext()
end

-- don't use treesitter folds for terminal
if vim.bo[buf].buftype == "terminal" then
return "0"
end
local line_count = vim.v.foldend - vim.v.foldstart - 1
local folded = {
{ " +" .. line_count .. " " .. (line_count == 1 and "line" or "lines") .. " ", "FoldedText" },
}

-- as long as we don't have a filetype, don't bother
-- checking if treesitter is available (it won't)
if vim.bo[buf].filetype == "" then
return "0"
for _, item in ipairs(folded) do
table.insert(result, item)
end

local ok = pcall(vim.treesitter.get_parser, buf)

if ok then
return vim.treesitter.foldexpr()
local result2 = M.parse_line(vim.v.foldend)
if result2 then
local first = result2[1]
result2[1] = { vim.trim(first[1]), first[2] }
for _, item in ipairs(result2) do
table.insert(result, item)
end
end

-- no parser available, so mark it as skip
-- in the next tick, all skip marks will be reset
M.skip_foldexpr[buf] = true
skip_check:start(function()
M.skip_foldexpr = {}
skip_check:stop()
M.skip_foldexpr = {}
skip_check:stop()
end)
return "0"
return result
end

function M.parse_line(linenr)
Expand Down Expand Up @@ -129,35 +127,6 @@ function M.parse_line(linenr)
return result
end

-- Based on https://github.com/Wansmer/nvim-config/blob/main/lua/modules/foldtext.lua
-- Which is based on https://www.reddit.com/r/neovim/comments/16sqyjz/finally_we_can_have_highlighted_folds/
function M.foldtext()
local result = M.parse_line(vim.v.foldstart)
if not result then
return vim.fn.foldtext()
end

local line_count = vim.v.foldend - vim.v.foldstart - 1
local folded = {
{ " +" .. line_count .. " " .. (line_count == 1 and "line" or "lines") .. " ", "FoldedText" },
}

for _, item in ipairs(folded) do
table.insert(result, item)
end

local result2 = M.parse_line(vim.v.foldend)
if result2 then
local first = result2[1]
result2[1] = { vim.trim(first[1]), first[2] }
for _, item in ipairs(result2) do
table.insert(result, item)
end
end

return result
end

function M.maximize()
---@type {k:string, v:any}[]?
local maximized = nil
Expand Down

0 comments on commit 700d804

Please sign in to comment.