Compare commits
No commits in common. "118bd28e2bce18fe49ed9b9e38f16b282ef115fe" and "b7d285a2a90cc0098444f733f96fa4b6f1757418" have entirely different histories.
118bd28e2b
...
b7d285a2a9
4
.bashrc
4
.bashrc
@ -28,10 +28,6 @@ if [ "$BASH" != "" ]; then
|
||||
if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
|
||||
. /etc/bash_completion
|
||||
fi
|
||||
|
||||
if [ -f /usr/share/bash-completion/completions/git ]; then
|
||||
source /usr/share/bash-completion/completions/git
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${OSTYPE}" == "linux-gnu"* ]]; then
|
||||
|
@ -116,13 +116,6 @@ vim.opt.cursorline = true
|
||||
-- Minimal number of screen lines to keep above and below the cursor.
|
||||
vim.opt.scrolloff = 10
|
||||
|
||||
vim.opt.fillchars = 'fold: '
|
||||
vim.wo.foldmethod = 'expr'
|
||||
vim.opt.foldlevel = 99
|
||||
vim.o.foldexpr = 'nvim_treesitter#foldexpr()'
|
||||
--vim.opt.foldtext = 'v:lua.vim.treesitter.foldtext()'
|
||||
vim.opt.foldtext = require 'modules.foldtext'
|
||||
|
||||
-- [[ Basic Keymaps ]]
|
||||
-- See `:help vim.keymap.set()`
|
||||
|
||||
@ -464,11 +457,6 @@ require('lazy').setup({
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
},
|
||||
config = function()
|
||||
-- Highlight codefences returned from denols.
|
||||
vim.g.markdown_fenced_languages = {
|
||||
'ts=typescript',
|
||||
}
|
||||
|
||||
-- LSP provides Neovim with features like:
|
||||
-- - Go to definition
|
||||
-- - Find references
|
||||
@ -581,12 +569,6 @@ require('lazy').setup({
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend('force', capabilities, require('cmp_nvim_lsp').default_capabilities())
|
||||
|
||||
-- Tell the server the capability of foldingRange, used by kevinhwang91/nvim-ufo
|
||||
capabilities.textDocument.foldingRange = {
|
||||
dynamicRegistration = false,
|
||||
lineFoldingOnly = true,
|
||||
}
|
||||
|
||||
-- Enable the following language servers
|
||||
-- Feel free to add/remove any LSPs that you want here. They will automatically be installed.
|
||||
--
|
||||
@ -611,15 +593,7 @@ require('lazy').setup({
|
||||
-- https://github.com/pmizio/typescript-tools.nvim
|
||||
--
|
||||
-- But for many setups, the LSP (`ts_ls`) will work just fine
|
||||
ts_ls = {
|
||||
enabled = true,
|
||||
},
|
||||
|
||||
-- Swap enabled state with ts_ls to use. Theoretically you can also configure these
|
||||
-- to only start when appropriate, but I haven't gotten that working yet.
|
||||
denols = {
|
||||
enabled = false,
|
||||
},
|
||||
ts_ls = {},
|
||||
|
||||
eslint_d = {},
|
||||
tailwindcss = {},
|
||||
|
@ -1,37 +0,0 @@
|
||||
-- The goal of nvim-ufo is to make Neovim's fold look modern and keep high performance.
|
||||
-- https://github.com/kevinhwang91/nvim-ufo
|
||||
return {
|
||||
{
|
||||
'kevinhwang91/nvim-ufo',
|
||||
enabled = false,
|
||||
dependencies = {
|
||||
'kevinhwang91/promise-async',
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
'neovim/nvim-lspconfig',
|
||||
},
|
||||
keys = {
|
||||
{
|
||||
'zR',
|
||||
function()
|
||||
require('ufo').openAllFolds()
|
||||
end,
|
||||
},
|
||||
{
|
||||
'zM',
|
||||
function()
|
||||
require('ufo').closeAllFolds()
|
||||
end,
|
||||
},
|
||||
-- { 'zr', function() require('ufo').openFoldsExceptKinds() end },
|
||||
-- { 'zm', function() require('ufo').closeFoldsWith() end },
|
||||
},
|
||||
opts = function()
|
||||
return {
|
||||
-- More advanced config example: https://github.com/rafi/vim-config/blob/master/lua/rafi/plugins/extras/editor/ufo.lua
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
return { 'treesitter', 'indent' }
|
||||
end,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
@ -1,129 +0,0 @@
|
||||
---@module Foldtext
|
||||
---Based on https://www.reddit.com/r/neovim/comments/16sqyjz/finally_we_can_have_highlighted_folds/
|
||||
---Retrieved from https://github.com/Wansmer/nvim-config/blob/main/lua/modules/foldtext.lua
|
||||
---Updated with vim.treesitter._fold.foldtext()
|
||||
|
||||
local function parse_line(linenr)
|
||||
local bufnr = vim.api.nvim_get_current_buf()
|
||||
|
||||
local line = vim.api.nvim_buf_get_lines(bufnr, linenr - 1, linenr, false)[1]
|
||||
if not line then
|
||||
return nil
|
||||
end
|
||||
|
||||
local ok, parser = pcall(vim.treesitter.get_parser, bufnr)
|
||||
if not ok then
|
||||
return nil
|
||||
end
|
||||
|
||||
local query = vim.treesitter.query.get(parser:lang(), 'highlights')
|
||||
if not query then
|
||||
return nil
|
||||
end
|
||||
|
||||
local tree = parser:parse({ linenr - 1, linenr })[1]
|
||||
|
||||
local result = {}
|
||||
|
||||
local line_pos = 0
|
||||
|
||||
for id, node, metadata in query:iter_captures(tree:root(), 0, linenr - 1, linenr) do
|
||||
local name = query.captures[id]
|
||||
local start_row, start_col, end_row, end_col = node:range()
|
||||
|
||||
local priority = tonumber(metadata.priority or vim.highlight.priorities.treesitter)
|
||||
|
||||
if start_row == linenr - 1 and end_row == linenr - 1 then
|
||||
-- check for characters ignored by treesitter
|
||||
if start_col > line_pos then
|
||||
table.insert(result, {
|
||||
line:sub(line_pos + 1, start_col),
|
||||
{ { 'Folded', priority } },
|
||||
range = { line_pos, start_col },
|
||||
})
|
||||
end
|
||||
line_pos = end_col
|
||||
|
||||
local text = line:sub(start_col + 1, end_col)
|
||||
table.insert(result, { text, { { '@' .. name, priority } }, range = { start_col, end_col } })
|
||||
end
|
||||
end
|
||||
|
||||
local i = 1
|
||||
while i <= #result do
|
||||
-- find first capture that is not in current range and apply highlights on the way
|
||||
local j = i + 1
|
||||
while j <= #result and result[j].range[1] >= result[i].range[1] and result[j].range[2] <= result[i].range[2] do
|
||||
for k, v in ipairs(result[i][2]) do
|
||||
if not vim.tbl_contains(result[j][2], v) then
|
||||
table.insert(result[j][2], k, v)
|
||||
end
|
||||
end
|
||||
j = j + 1
|
||||
end
|
||||
|
||||
-- remove the parent capture if it is split into children
|
||||
if j > i + 1 then
|
||||
table.remove(result, i)
|
||||
else
|
||||
-- highlights need to be sorted by priority, on equal prio, the deeper nested capture (earlier
|
||||
-- in list) should be considered higher prio
|
||||
if #result[i][2] > 1 then
|
||||
table.sort(result[i][2], function(a, b)
|
||||
return a[2] < b[2]
|
||||
end)
|
||||
end
|
||||
|
||||
result[i][2] = vim.tbl_map(function(tbl)
|
||||
return tbl[1]
|
||||
end, result[i][2])
|
||||
result[i] = { result[i][1], result[i][2] }
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
function HighlightedFoldtext()
|
||||
local result = parse_line(vim.v.foldstart)
|
||||
if not result then
|
||||
return vim.fn.foldtext()
|
||||
end
|
||||
|
||||
local folded = {
|
||||
{ ' ', 'FoldedIcon' },
|
||||
{ '+' .. vim.v.foldend - vim.v.foldstart .. ' lines', 'FoldedText' },
|
||||
{ ' ', 'FoldedIcon' },
|
||||
}
|
||||
|
||||
for _, item in ipairs(folded) do
|
||||
table.insert(result, item)
|
||||
end
|
||||
|
||||
local result2 = 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
|
||||
|
||||
local function set_fold_hl()
|
||||
local cl = vim.api.nvim_get_hl(0, { name = 'CursorLineNr' })
|
||||
vim.api.nvim_set_hl(0, 'FoldedIcon', { fg = cl.bg })
|
||||
vim.api.nvim_set_hl(0, 'FoldedText', { bg = cl.bg, fg = cl.fg, italic = true })
|
||||
end
|
||||
|
||||
set_fold_hl()
|
||||
|
||||
vim.api.nvim_create_autocmd('ColorScheme', {
|
||||
callback = set_fold_hl,
|
||||
})
|
||||
|
||||
return 'luaeval("HighlightedFoldtext")()'
|
Loading…
Reference in New Issue
Block a user