Skip to content

Commit

Permalink
feat(nvim-treesitter): add 'ensure_installed' sample module for trees…
Browse files Browse the repository at this point in the history
…itter parsers (#567)

refactor(neo-tree.nvim): use default renderers (#567)
  • Loading branch information
linrongbin16 committed May 15, 2024
1 parent 01dec07 commit 443b0b2
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 82 deletions.
2 changes: 0 additions & 2 deletions lua/configs/RRethy/vim-illuminate/config.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
local constants = require("builtin.constants")

require("illuminate").configure({
-- delay: delay in milliseconds
delay = 300,
-- disable cursor word for big file
large_file_cutoff = constants.perf.maxfilesize,
})
Expand Down
8 changes: 2 additions & 6 deletions lua/configs/akinsho/bufferline-nvim/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ local str = require("commons.str")

require("bufferline").setup({
options = {
-- numbers = function(opts)
-- return string.format("%s.%s", opts.ordinal, opts.lower(opts.id))
-- end,
numbers = "ordinal",
close_command = "Bdelete! %d", -- Bdelete: https://github.com/moll/vim-bbye
right_mouse_command = "Bdelete! %d",
close_command = "Bdelete! %d", -- vim-bbye
right_mouse_command = "Bdelete! %d", -- vim-bbye
name_formatter = function(buf)
local max_name_len = layout.editor.width(0.334, 60, nil)
local name = buf.name
Expand All @@ -25,7 +22,6 @@ require("bufferline").setup({
max_name_length = layout.editor.width(0.334, 60, nil),
max_prefix_length = layout.editor.width(0.1, 10, 18),
diagnostics = false,
-- separator_style = "slant",
get_element_icon = function(element)
local current_bufpath = vim.api.nvim_buf_get_name(0)
local icon_text, icon_color =
Expand Down
33 changes: 19 additions & 14 deletions lua/configs/akinsho/bufferline-nvim/keys.lua
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
local set_lazy_key = require("builtin.utils.keymap").set_lazy_key

local M = {
-- go to the last buffer
set_lazy_key(
"n",
"<leader>0",
"<cmd>lua require('bufferline').go_to_buffer(-1, true)<cr>",
{ desc = "Go to the last buffer" }
),

-- go to next/previous buffer
set_lazy_key("n", "]b", "<cmd>BufferLineCycleNext<cr>", { desc = "Go to next buffer" }),
set_lazy_key("n", "[b", "<cmd>BufferLineCyclePrev<cr>", { desc = "Go to previous buffer" }),
set_lazy_key("n", "]b", "<cmd>BufferLineCycleNext<cr>", { desc = "Go to next(right) buffer" }),
set_lazy_key("n", "[b", "<cmd>BufferLineCyclePrev<cr>", { desc = "Go to previous(left) buffer" }),

-- move/re-order buffer to next/previous position
set_lazy_key("n", "<leader>.", "<cmd>BufferLineMoveNext<cr>", { desc = "Move buffer to next" }),
set_lazy_key(
"n",
"<leader>.",
"<cmd>BufferLineMoveNext<cr>",
{ desc = "Move buffer to next(right)" }
),
set_lazy_key(
"n",
"<leader>,",
"<cmd>BufferLineMovePrev<cr>",
{ desc = "Move buffer to previous" }
{ desc = "Move buffer to previous(left)" }
),

-- go to the last buffer
set_lazy_key(
"n",
"<leader>0",
"<cmd>lua require('bufferline').go_to(-1, true)<cr>",
{ desc = "Go to last buffer" }
),
}

Expand All @@ -30,8 +35,8 @@ for i = 1, 9 do
set_lazy_key(
"n",
string.format("<leader>%d", i),
string.format("<cmd>lua require('bufferline').go_to_buffer(%d, true)<cr>", i),
{ desc = string.format("Go to buffer-%d", i) }
string.format("<cmd>lua require('bufferline').go_to(%d, true)<cr>", i),
{ desc = string.format("Go to %d buffer", i) }
)
)
end
Expand Down
1 change: 0 additions & 1 deletion lua/configs/brenoprata10/nvim-highlight-colors/config.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require("nvim-highlight-colors").setup({
render = "background",
enable_named_colors = true,
enable_tailwind = true,
})
4 changes: 2 additions & 2 deletions lua/configs/jay-babu/mason-null-ls-nvim/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if user_ensure_installed_ok then
if type(user_ensure_installed) == "table" then
ensure_installed = user_ensure_installed
else
message.warn(string.format("Error loading '%s' lua module!", user_ensure_installed_module))
message.err(string.format("Error loading '%s' lua module!", user_ensure_installed_module))
end
end

Expand All @@ -22,7 +22,7 @@ if user_setup_handlers_ok then
if type(user_setup_handlers) == "table" then
setup_handlers = user_setup_handlers
else
message.warn(string.format("Error loading '%s' lua module!", user_setup_handlers_module))
message.err(string.format("Error loading '%s' lua module!", user_setup_handlers_module))
end
end

Expand Down
47 changes: 2 additions & 45 deletions lua/configs/nvim-neo-tree/neo-tree-nvim/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,51 +39,8 @@ require("neo-tree").setup({
conflict = "", -- nf-dev-git_merge \ue727
},
},
},
renderers = {
directory = {
{ "indent" },
{ "icon" },
{ "current_filter" },
{
"container",
content = {
{ "name", zindex = 10 },
{
"symlink_target",
zindex = 10,
highlight = "NeoTreeSymbolicLinkTarget",
},
{ "clipboard", zindex = 10 },
{
"git_status",
zindex = 20,
align = "right",
hide_when_expanded = true,
},
},
},
},
file = {
{ "indent" },
{ "icon" },
{
"container",
content = {
{
"name",
zindex = 10,
},
{
"symlink_target",
zindex = 10,
highlight = "NeoTreeSymbolicLinkTarget",
},
{ "clipboard", zindex = 10 },
{ "modified", zindex = 20, align = "left" },
{ "git_status", zindex = 20, align = "right" },
},
},
symlink_target = {
enabled = true,
},
},
window = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require("treesitter-context").setup({
max_lines = 1,
min_window_height = 30,
trim_scope = "outer",
min_window_height = 20,
})
21 changes: 13 additions & 8 deletions lua/configs/nvim-treesitter/nvim-treesitter/config.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
local constants = require("builtin.constants")
local message = require("builtin.utils.message")
local uv = vim.uv or vim.loop

local ensure_installed = {
"vim",
"lua",
"markdown",
"javascript",
"typescript",
"tsx",
}
local ensure_installed = {}

local user_ensure_installed_module = "configs.nvim-treesitter.nvim-treesitter.ensure_installed"
local user_ensure_installed_ok, user_ensure_installed = pcall(require, user_ensure_installed_module)

if user_ensure_installed_ok then
if type(user_ensure_installed) == "table" then
ensure_installed = user_ensure_installed
else
message.err(string.format("Error loading '%s' lua module!", user_ensure_installed_module))
end
end

---@diagnostic disable-next-line: missing-fields
require("nvim-treesitter.configs").setup({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Please copy this file to 'ensure_installed.lua' to enable it.

-- Ensure installed nvim-treesitter parsers.
-- This module will be passed to `require("nvim-treesitter.configs").setup({ ensure_installed = ... })`.

local ensure_installed = {
"vim", -- vim
"lua", -- lua
"markdown", -- markdown
"javascript", -- javascript
"typescript", -- typescript
"tsx", -- jsx/tsx
}

return ensure_installed
4 changes: 2 additions & 2 deletions lua/configs/williamboman/mason-lspconfig-nvim/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if user_ensure_installed_ok then
if type(user_ensure_installed) == "table" then
ensure_installed = user_ensure_installed
else
message.warn(string.format("Error loading '%s' lua module!", user_ensure_installed_module))
message.err(string.format("Error loading '%s' lua module!", user_ensure_installed_module))
end
end

Expand All @@ -32,7 +32,7 @@ if user_setup_handlers_ok then
setup_handlers[name] = handler
end
else
message.warn(string.format("Error loading '%s' lua module!", user_setup_handlers_module))
message.err(string.format("Error loading '%s' lua module!", user_setup_handlers_module))
end
end

Expand Down

0 comments on commit 443b0b2

Please sign in to comment.