feat(nvim): treesitter enable and Snacks
This commit is contained in:
+44
-29
@@ -120,14 +120,50 @@ vim.pack.add({
|
|||||||
'https://github.com/nvim-tree/nvim-web-devicons',
|
'https://github.com/nvim-tree/nvim-web-devicons',
|
||||||
})
|
})
|
||||||
|
|
||||||
|
local treesitter = require('nvim-treesitter')
|
||||||
|
vim.api.nvim_create_autocmd('FileType', {
|
||||||
|
callback = function(args)
|
||||||
|
if
|
||||||
|
vim.list_contains(
|
||||||
|
treesitter.get_installed(),
|
||||||
|
vim.treesitter.language.get_lang(args.match)
|
||||||
|
)
|
||||||
|
then
|
||||||
|
vim.treesitter.start(args.buf)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- colorscheme --
|
-- colorscheme --
|
||||||
require('onedark').setup({ style = 'dark' })
|
require('onedark').setup({ style = 'dark' })
|
||||||
require('onedark').load()
|
require('onedark').load()
|
||||||
|
|
||||||
|
|
||||||
-- mini --
|
-- mini --
|
||||||
require('mini.icons').setup()
|
require('mini.icons').setup()
|
||||||
require('mini.surround').setup()
|
require('mini.surround').setup()
|
||||||
|
|
||||||
|
-- snacks --
|
||||||
|
require('snacks').setup({
|
||||||
|
bigfile = { enabled = true },
|
||||||
|
notifier = { enabled = true },
|
||||||
|
notify = { enabled = true },
|
||||||
|
quickfile = { enabled = true },
|
||||||
|
statuscolumn = { enabled = true },
|
||||||
|
input = { enabled = true },
|
||||||
|
image = {
|
||||||
|
doc = {
|
||||||
|
inline = false,
|
||||||
|
float = true,
|
||||||
|
max_width = 10,
|
||||||
|
max_height = 5,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
words = {
|
||||||
|
debounce = 10
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
require('mini.pairs').setup({
|
require('mini.pairs').setup({
|
||||||
mappings = {
|
mappings = {
|
||||||
-- Prevents the action if the cursor is just before any character or next to a "\".
|
-- Prevents the action if the cursor is just before any character or next to a "\".
|
||||||
@@ -153,27 +189,6 @@ require('mini.ai').setup({
|
|||||||
n_lines = 1000
|
n_lines = 1000
|
||||||
})
|
})
|
||||||
|
|
||||||
-- snacks --
|
|
||||||
require('snacks').setup({
|
|
||||||
bigfile = { enabled = true },
|
|
||||||
notifier = { enabled = true },
|
|
||||||
notify = { enabled = true },
|
|
||||||
quickfile = { enabled = true },
|
|
||||||
statuscolumn = { enabled = true },
|
|
||||||
input = { enabled = true },
|
|
||||||
image = {
|
|
||||||
doc = {
|
|
||||||
inline = false,
|
|
||||||
float = true,
|
|
||||||
max_width = 10,
|
|
||||||
max_height = 5,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
words = {
|
|
||||||
debounce = 10
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
-- tiny-glimmer --
|
-- tiny-glimmer --
|
||||||
require('tiny-glimmer').setup({
|
require('tiny-glimmer').setup({
|
||||||
overwrite = {
|
overwrite = {
|
||||||
@@ -574,7 +589,7 @@ function RenderWinbar()
|
|||||||
}
|
}
|
||||||
for dir_name, dir_path in pairs(special_dirs) do
|
for dir_name, dir_path in pairs(special_dirs) do
|
||||||
if vim.startswith(path, vim.fs.normalize(dir_path)) and #dir_path > #prefix_path then
|
if vim.startswith(path, vim.fs.normalize(dir_path)) and #dir_path > #prefix_path then
|
||||||
prefix, prefix_path, folder_icon = dir_name, dir_path, MiniIcons.get('file',path)
|
prefix, prefix_path, folder_icon = dir_name, dir_path, MiniIcons.get('file', path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if prefix ~= '' then
|
if prefix ~= '' then
|
||||||
@@ -595,10 +610,10 @@ function RenderWinbar()
|
|||||||
prefix,
|
prefix,
|
||||||
table.concat(
|
table.concat(
|
||||||
vim.iter(vim.split(path, '/'))
|
vim.iter(vim.split(path, '/'))
|
||||||
:map(function(segment)
|
:map(function(segment)
|
||||||
return string.format('%%#Winbar#%s', segment)
|
return string.format('%%#Winbar#%s', segment)
|
||||||
end)
|
end)
|
||||||
:totable(),
|
:totable(),
|
||||||
separator
|
separator
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
@@ -609,10 +624,10 @@ vim.api.nvim_create_autocmd('BufWinEnter', {
|
|||||||
desc = 'Attach winbar',
|
desc = 'Attach winbar',
|
||||||
callback = function(args)
|
callback = function(args)
|
||||||
if
|
if
|
||||||
not vim.api.nvim_win_get_config(0).zindex -- Not a floating window
|
not vim.api.nvim_win_get_config(0).zindex -- Not a floating window
|
||||||
and vim.bo[args.buf].buftype == '' -- Normal buffer
|
and vim.bo[args.buf].buftype == '' -- Normal buffer
|
||||||
and vim.api.nvim_buf_get_name(args.buf) ~= '' -- Has a file name
|
and vim.api.nvim_buf_get_name(args.buf) ~= '' -- Has a file name
|
||||||
and not vim.wo[0].diff -- Not in diff mode
|
and not vim.wo[0].diff -- Not in diff mode
|
||||||
then
|
then
|
||||||
vim.wo.winbar = "%{%v:lua.RenderWinbar()%}"
|
vim.wo.winbar = "%{%v:lua.RenderWinbar()%}"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user