(nvim) format all lua files

This commit is contained in:
juancwu 2025-09-05 09:39:31 -04:00
commit 9844c832ba
32 changed files with 1200 additions and 1186 deletions

View file

@ -1,58 +1,58 @@
local Utils = require("juancwu.utils") local Utils = require("juancwu.utils")
if Utils.os.is_linux() then if Utils.os.is_linux() then
local wayland_display = os.getenv("WAYLAND_DISPLAY") local wayland_display = os.getenv("WAYLAND_DISPLAY")
if Utils.os.is_wsl() then if Utils.os.is_wsl() then
vim.g.clipboard = { vim.g.clipboard = {
name = "win32yank", name = "win32yank",
copy = { copy = {
["+"] = "win32yank.exe -i --crlf", ["+"] = "win32yank.exe -i --crlf",
["*"] = "win32yank.exe -i --crlf", ["*"] = "win32yank.exe -i --crlf",
}, },
paste = { paste = {
["+"] = "win32yank.exe -o --lf", ["+"] = "win32yank.exe -o --lf",
["*"] = "win32yank.exe -o --lf", ["*"] = "win32yank.exe -o --lf",
}, },
cache_enabled = 0, cache_enabled = 0,
} }
elseif wayland_display then elseif wayland_display then
vim.g.clipboard = { vim.g.clipboard = {
name = "wl-clipboard", name = "wl-clipboard",
copy = { copy = {
["+"] = "wl-copy", ["+"] = "wl-copy",
["*"] = "wl-copy", ["*"] = "wl-copy",
}, },
paste = { paste = {
["+"] = "wl-paste", ["+"] = "wl-paste",
["*"] = "wl-paste", ["*"] = "wl-paste",
}, },
cache_enabled = 1, cache_enabled = 1,
} }
else else
vim.g.clipboard = { vim.g.clipboard = {
name = "xclip", name = "xclip",
copy = { copy = {
["+"] = "xclip -sel clip -i -quiet", ["+"] = "xclip -sel clip -i -quiet",
["*"] = "xclip -sel primary -i -quiet", ["*"] = "xclip -sel primary -i -quiet",
}, },
paste = { paste = {
["+"] = "xclip -sel clip -o -quiet", ["+"] = "xclip -sel clip -o -quiet",
["*"] = "xclip -sel primary -o -quiet", ["*"] = "xclip -sel primary -o -quiet",
}, },
cache_enabled = 1, cache_enabled = 1,
} }
end end
elseif Utils.os.is_mac() then elseif Utils.os.is_mac() then
vim.g.clipboard = { vim.g.clipboard = {
name = "mac-clipboard", name = "mac-clipboard",
copy = { copy = {
["+"] = "pbcopy", ["+"] = "pbcopy",
["*"] = "pbcopy", ["*"] = "pbcopy",
}, },
paste = { paste = {
["+"] = "pbpaste", ["+"] = "pbpaste",
["*"] = "pbpaste", ["*"] = "pbpaste",
}, },
cache_enabled = 1, cache_enabled = 1,
} }
end end

View file

@ -3,22 +3,22 @@ local M = {}
---@class ConfigOptions ---@class ConfigOptions
local defaultOpts = { local defaultOpts = {
---@type string | fun() ---@type string | fun()
colorscheme = "rose-pine", colorscheme = "rose-pine",
} }
vim.g.disable_autoformat = false vim.g.disable_autoformat = false
---@param name "options" | "keymaps" | "clipboard" ---@param name "options" | "keymaps" | "clipboard"
function M.load(name) function M.load(name)
local mod = "juancwu.config." .. name local mod = "juancwu.config." .. name
local error_handler = function(err) local error_handler = function(err)
local msg = "Failed loading " .. mod .. "\n\n" .. err local msg = "Failed loading " .. mod .. "\n\n" .. err
print(msg) print(msg)
end end
xpcall(function() xpcall(function()
require(mod) require(mod)
end, error_handler) end, error_handler)
end end
---@type ConfigOptions ---@type ConfigOptions
@ -26,55 +26,55 @@ local options
---@param opts? ConfigOptions ---@param opts? ConfigOptions
function M.setup(opts) function M.setup(opts)
options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {} options = vim.tbl_deep_extend("force", defaultOpts, opts or {}) or {}
M.load("options") M.load("options")
M.load("keymaps") M.load("keymaps")
M.load("clipboard") M.load("clipboard")
require("lazy").setup("juancwu.plugins") require("lazy").setup("juancwu.plugins")
-- try to load colorscheme -- try to load colorscheme
xpcall(function() xpcall(function()
if type(M.colorscheme) == "function" then if type(M.colorscheme) == "function" then
M.colorscheme() M.colorscheme()
else else
vim.cmd.colorscheme(M.colorscheme) vim.cmd.colorscheme(M.colorscheme)
end end
end, function(err) end, function(err)
if type(M.colorscheme) == "string" then if type(M.colorscheme) == "string" then
local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err local msg = "Failed to load colorscheme " .. M.colorscheme .. "\n\n" .. err
print(msg) print(msg)
else else
print("Failed to load colorscheme\n\n" .. err) print("Failed to load colorscheme\n\n" .. err)
end end
vim.cmd.colorscheme("rose-pine") vim.cmd.colorscheme("rose-pine")
end) end)
-- create command to disable autoformat -- create command to disable autoformat
vim.api.nvim_create_user_command("FormatDisable", function(args) vim.api.nvim_create_user_command("FormatDisable", function(args)
vim.g.disable_autoformat = true vim.g.disable_autoformat = true
end, { desc = "Disable Autoformat" }) end, { desc = "Disable Autoformat" })
vim.api.nvim_create_user_command("FormatEnable", function(args) vim.api.nvim_create_user_command("FormatEnable", function(args)
vim.g.disable_autoformat = false vim.g.disable_autoformat = false
end, { desc = "Enable Autoformat" }) end, { desc = "Enable Autoformat" })
-- create command to toggle colorscheme -- create command to toggle colorscheme
vim.api.nvim_create_user_command( vim.api.nvim_create_user_command(
"ToggleColors", "ToggleColors",
require("juancwu.utils.colors").toggle_colors, require("juancwu.utils.colors").toggle_colors,
{ desc = "Toggle colorscheme" } { desc = "Toggle colorscheme" }
) )
end end
setmetatable(M, { setmetatable(M, {
__index = function(_, k) __index = function(_, k)
if options == nil then if options == nil then
return vim.deepcopy(defaultOpts)[k] return vim.deepcopy(defaultOpts)[k]
end end
return options[k] return options[k]
end, end,
}) })
return M return M

View file

@ -1,7 +1,7 @@
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = " " vim.g.maplocalleader = " "
vim.opt.number = true -- show line number vim.opt.number = true -- show line number
vim.opt.relativenumber = true -- juicy relativity vim.opt.relativenumber = true -- juicy relativity
vim.opt.autoindent = true vim.opt.autoindent = true
@ -18,7 +18,7 @@ vim.opt.wrap = false -- bad, stay away from me!
vim.opt.hlsearch = false vim.opt.hlsearch = false
vim.opt.incsearch = true -- highlight search pattern as you type vim.opt.incsearch = true -- highlight search pattern as you type
vim.opt.scrolloff = 12 -- give me some personal space vim.opt.scrolloff = 12 -- give me some personal space
vim.opt.updatetime = 50 vim.opt.updatetime = 50
@ -45,11 +45,11 @@ vim.opt.undofile = true
-- highlight on yank -- highlight on yank
local highligh_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) local highligh_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true })
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
callback = function() callback = function()
vim.highlight.on_yank() vim.highlight.on_yank()
end, end,
group = highligh_group, group = highligh_group,
pattern = "*", pattern = "*",
}) })
vim.opt.completeopt = "menu,menuone,noselect" vim.opt.completeopt = "menu,menuone,noselect"

View file

@ -2,7 +2,7 @@ local M = {}
---@param opts? ConfigOptions ---@param opts? ConfigOptions
function M.setup(opts) function M.setup(opts)
require("juancwu.config").setup(opts) require("juancwu.config").setup(opts)
end end
return M return M

View file

@ -1,93 +1,93 @@
return { -- Autocompletion return { -- Autocompletion
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
event = "InsertEnter", event = "InsertEnter",
dependencies = { dependencies = {
-- Snippet Engine & its associated nvim-cmp source -- Snippet Engine & its associated nvim-cmp source
{ {
"L3MON4D3/LuaSnip", "L3MON4D3/LuaSnip",
build = (function() build = (function()
-- Build Step is needed for regex support in snippets. -- Build Step is needed for regex support in snippets.
-- This step is not supported in many windows environments. -- This step is not supported in many windows environments.
-- Remove the below condition to re-enable on windows. -- Remove the below condition to re-enable on windows.
if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then if vim.fn.has("win32") == 1 or vim.fn.executable("make") == 0 then
return return
end end
return "make install_jsregexp" return "make install_jsregexp"
end)(), end)(),
dependencies = { dependencies = {
{ {
"rafamadriz/friendly-snippets", "rafamadriz/friendly-snippets",
config = function() config = function()
require("luasnip.loaders.from_vscode").lazy_load() require("luasnip.loaders.from_vscode").lazy_load()
end, end,
}, },
}, },
}, },
"saadparwaiz1/cmp_luasnip", "saadparwaiz1/cmp_luasnip",
"hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-nvim-lsp",
"hrsh7th/cmp-path", "hrsh7th/cmp-path",
}, },
config = function() config = function()
-- See `:help cmp` -- See `:help cmp`
local cmp = require("cmp") local cmp = require("cmp")
local luasnip = require("luasnip") local luasnip = require("luasnip")
luasnip.config.setup({}) luasnip.config.setup({})
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args)
luasnip.lsp_expand(args.body) luasnip.lsp_expand(args.body)
end, end,
}, },
completion = { completeopt = "menu,menuone,noinsert" }, completion = { completeopt = "menu,menuone,noinsert" },
-- For an understanding of why these mappings were -- For an understanding of why these mappings were
-- chosen, you will need to read `:help ins-completion` -- chosen, you will need to read `:help ins-completion`
-- --
-- No, but seriously. Please read `:help ins-completion`, it is really good! -- No, but seriously. Please read `:help ins-completion`, it is really good!
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
-- Select the [n]ext item -- Select the [n]ext item
["<C-n>"] = cmp.mapping.select_next_item(), ["<C-n>"] = cmp.mapping.select_next_item(),
-- Select the [p]revious item -- Select the [p]revious item
["<C-p>"] = cmp.mapping.select_prev_item(), ["<C-p>"] = cmp.mapping.select_prev_item(),
-- Scroll the documentation window [b]ack / [f]orward -- Scroll the documentation window [b]ack / [f]orward
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
-- Accept ([y]es) the completion. -- Accept ([y]es) the completion.
-- This will auto-import if your LSP supports it. -- This will auto-import if your LSP supports it.
-- This will expand snippets if the LSP sent a snippet. -- This will expand snippets if the LSP sent a snippet.
["<CR>"] = cmp.mapping.confirm({ select = true }), ["<CR>"] = cmp.mapping.confirm({ select = true }),
-- Manually trigger a completion from nvim-cmp. -- Manually trigger a completion from nvim-cmp.
-- Generally you don't need this, because nvim-cmp will display -- Generally you don't need this, because nvim-cmp will display
-- completions whenever it has completion options available. -- completions whenever it has completion options available.
["<C-Space>"] = cmp.mapping.complete({}), ["<C-Space>"] = cmp.mapping.complete({}),
-- <c-l> will move you to the right of each of the expansion locations. -- <c-l> will move you to the right of each of the expansion locations.
-- <c-h> is similar, except moving you backwards. -- <c-h> is similar, except moving you backwards.
["<C-l>"] = cmp.mapping(function() ["<C-l>"] = cmp.mapping(function()
if luasnip.expand_or_locally_jumpable() then if luasnip.expand_or_locally_jumpable() then
luasnip.expand_or_jump() luasnip.expand_or_jump()
end end
end, { "i", "s" }), end, { "i", "s" }),
["<C-h>"] = cmp.mapping(function() ["<C-h>"] = cmp.mapping(function()
if luasnip.locally_jumpable(-1) then if luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
end end
end, { "i", "s" }), end, { "i", "s" }),
}), }),
sources = { sources = {
{ {
name = "lazydev", name = "lazydev",
-- set group index to 0 to skip loading LuaLS completions as lazydev recommends it -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it
group_index = 0, group_index = 0,
}, },
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "path" }, { name = "path" },
}, },
}) })
end, end,
} }

View file

@ -1,11 +1,11 @@
return { return {
"windwp/nvim-autopairs", "windwp/nvim-autopairs",
event = "InsertEnter", event = "InsertEnter",
dependencies = { "hrsh7th/nvim-cmp" }, dependencies = { "hrsh7th/nvim-cmp" },
config = function() config = function()
require("nvim-autopairs").setup({}) require("nvim-autopairs").setup({})
local cmp_autopairs = require("nvim-autopairs.completion.cmp") local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp") local cmp = require("cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end, end,
} }

View file

@ -1,30 +1,30 @@
return { return {
"windwp/nvim-ts-autotag", "windwp/nvim-ts-autotag",
dependencies = { "nvim-treesitter/nvim-treesitter", build = ':TSUpdate' }, dependencies = { "nvim-treesitter/nvim-treesitter", build = ":TSUpdate" },
ft = { ft = {
'html', "html",
'javascript', "javascript",
'typescript', "typescript",
'javascriptreact', "javascriptreact",
'typescriptreact', "typescriptreact",
'svelte', "svelte",
'vue', "vue",
'tsx', "tsx",
'jsx', "jsx",
'xml', "xml",
'php', "php",
'markdown', "markdown",
'astro', "astro",
'glimmer', "glimmer",
'handlebars', "handlebars",
'hbs', "hbs",
'templ', "templ",
}, },
config = function() config = function()
local autotag = require('nvim-ts-autotag') local autotag = require("nvim-ts-autotag")
autotag.setup({ autotag.setup({
enable = true, enable = true,
enable_close_on_slash = false, enable_close_on_slash = false,
}) })
end end,
} }

View file

@ -1,47 +1,47 @@
return { return {
-- rose-pine -- rose-pine
{ {
"rose-pine/nvim", "rose-pine/nvim",
name = "rose-pine", name = "rose-pine",
priority = 1000, priority = 1000,
}, },
-- onedark -- onedark
{ {
"navarasu/onedark.nvim", "navarasu/onedark.nvim",
priority = 1000, priority = 1000,
}, },
-- solarized-osaka -- solarized-osaka
{ {
"craftzdog/solarized-osaka.nvim", "craftzdog/solarized-osaka.nvim",
priority = 1000, priority = 1000,
opts = { opts = {
transparent = false, transparent = false,
}, },
}, },
-- tokyonight -- tokyonight
{ {
"folke/tokyonight.nvim", "folke/tokyonight.nvim",
lazy = true, lazy = true,
opts = { style = "moon" }, opts = { style = "moon" },
}, },
-- catppuccin -- catppuccin
{ {
"catppuccin/nvim", "catppuccin/nvim",
lazy = true, lazy = true,
name = "catppuccin", name = "catppuccin",
priority = 1000, priority = 1000,
opts = { opts = {
flavour = "mocha", flavour = "mocha",
}, },
}, },
-- great kanagawa -- great kanagawa
{ {
"rebelot/kanagawa.nvim", "rebelot/kanagawa.nvim",
opts = {}, opts = {},
}, },
} }

View file

@ -1,34 +1,33 @@
return { return {
"numToStr/Comment.nvim", "numToStr/Comment.nvim",
dependencies = { dependencies = {
"JoosepAlviste/nvim-ts-context-commentstring", "JoosepAlviste/nvim-ts-context-commentstring",
}, },
config = function() config = function()
local comment = require('Comment') local comment = require("Comment")
comment.setup({ comment.setup({
pre_hook = function(ctx) pre_hook = function(ctx)
-- only for tsx/jsx filetypes -- only for tsx/jsx filetypes
if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then if vim.bo.filetype == "typescriptreact" or vim.bo.filetype == "javascriptreact" then
local U = require('Comment.utils') local U = require("Comment.utils")
-- determine wheter to use linwise or blockwise commentstring -- determine wheter to use linwise or blockwise commentstring
local type = ctx.ctype == U.ctype.linewise and '__default' or '__multiline' local type = ctx.ctype == U.ctype.linewise and "__default" or "__multiline"
-- determine the location where to calcualte commentstring from
local location = nil
if ctx.ctype == U.ctype.blockwise then
location = require("ts_context_commentstring.utils").get_cursor_location()
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
location = require("ts_context_commentstring.utils").get_visual_start_location()
end
-- determine the location where to calcualte commentstring from return require("ts_context_commentstring.internal").calculate_commentstring({
local location = nil key = type,
if ctx.ctype == U.ctype.blockwise then location = location,
location = require('ts_context_commentstring.utils').get_cursor_location() })
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then end
location = require('ts_context_commentstring.utils').get_visual_start_location() end,
end })
end,
return require('ts_context_commentstring.internal').calculate_commentstring({
key = type,
location = location,
})
end
end,
})
end
} }

View file

@ -1,61 +1,60 @@
local formatters_by_ft = { local formatters_by_ft = {
lua = { "stylua" }, lua = { "stylua" },
javascript = { "biome" }, javascript = { "biome" },
typescript = { "biome" }, typescript = { "biome" },
javascriptreact = { "biome" }, javascriptreact = { "biome" },
typescriptreact = { "biome" }, typescriptreact = { "biome" },
css = { "biome" }, css = { "biome" },
markdown = { "biome" }, markdown = { "biome" },
jsonc = { "biome" }, jsonc = { "biome" },
json = { "biome" }, json = { "biome" },
go = { "gofmt", "goimports" }, go = { "gofmt", "goimports" },
python = { "autopep8" }, python = { "autopep8" },
yaml = { "yamlfmt" }, yaml = { "yamlfmt" },
yml = { "yamlfmt" }, yml = { "yamlfmt" },
zig = { "zigfmt" }, zig = { "zigfmt" },
rust = { "rustfmt" }, rust = { "rustfmt" },
} }
return { return {
"stevearc/conform.nvim", "stevearc/conform.nvim",
event = { "BufWritePre", "BufEnter" }, event = { "BufWritePre", "BufEnter" },
cmd = { "ConformInfo" }, cmd = { "ConformInfo" },
keys = { keys = {
{ {
"<leader>ff", "<leader>ff",
function() function()
require("conform").format({ async = true, lsp_format = "fallback" }) require("conform").format({ async = true, lsp_format = "fallback" })
end, end,
mode = "", mode = "",
desc = "[F]ormat buffer", desc = "[F]ormat buffer",
}, },
}, },
config = function() config = function()
require("conform").setup({ require("conform").setup({
notify_on_error = false, notify_on_error = false,
formatters_by_ft = formatters_by_ft, formatters_by_ft = formatters_by_ft,
format_on_save = function(bufnr) format_on_save = function(bufnr)
if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then if vim.g.disable_autoformat or vim.b[bufnr].disable_autoformat then
return return
end end
return { return {
timeout_ms = 500, timeout_ms = 500,
lsp_format = "fallback", lsp_format = "fallback",
} }
end, end,
}) })
vim.api.nvim_create_user_command("FormatDisable", function() vim.api.nvim_create_user_command("FormatDisable", function()
vim.g.disable_autoformat = true vim.g.disable_autoformat = true
end, { end, {
desc = "Disable autoformat on save", desc = "Disable autoformat on save",
}) })
vim.api.nvim_create_user_command("FormatEnable", function() vim.api.nvim_create_user_command("FormatEnable", function()
vim.g.disable_autoformat = false vim.g.disable_autoformat = false
end, { end, {
desc = "Enable autoformat on save", desc = "Enable autoformat on save",
}) })
end, end,
} }

View file

@ -1,23 +1,23 @@
return { return {
"tpope/vim-fugitive", "tpope/vim-fugitive",
cmd = { cmd = {
"Git", "Git",
"G", "G",
"Gdiffsplit", "Gdiffsplit",
"Gread", "Gread",
"Gwrite", "Gwrite",
"Ggrep", "Ggrep",
"GMove", "GMove",
"GDelete", "GDelete",
"GBrowse", "GBrowse",
"GRemove", "GRemove",
"GRename", "GRename",
"Glgrep", "Glgrep",
"Gedit" "Gedit",
}, },
keys = { keys = {
{ "<leader>gs", "<cmd>Git<CR>", desc = "Git status" }, { "<leader>gs", "<cmd>Git<CR>", desc = "Git status" },
{ "<leader>gbl", "<cmd>Git blame<CR>", desc = "Open [G]it [Bl]ame" }, { "<leader>gbl", "<cmd>Git blame<CR>", desc = "Open [G]it [Bl]ame" },
{ "<leader>gd", "<cmd>Gdiffsplit<CR>", desc = "Open [G]it [D]iff" }, { "<leader>gd", "<cmd>Gdiffsplit<CR>", desc = "Open [G]it [D]iff" },
}, },
} }

View file

@ -1,19 +1,19 @@
return { return {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
opts = { opts = {
current_line_blame = true, current_line_blame = true,
current_line_blame_opts = { current_line_blame_opts = {
virt_text = true, virt_text = true,
virt_text_pos = 'eol', virt_text_pos = "eol",
delay = 1000, delay = 1000,
ignore_whitespace = false ignore_whitespace = false,
},
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '-' },
changedelete = { text = '~' },
},
}, },
signs = {
add = { text = "+" },
change = { text = "~" },
delete = { text = "_" },
topdelete = { text = "-" },
changedelete = { text = "~" },
},
},
} }

View file

@ -1,20 +1,20 @@
return { return {
"fredrikaverpil/godoc.nvim", "fredrikaverpil/godoc.nvim",
version = "*", version = "*",
dependencies = { dependencies = {
{ "nvim-telescope/telescope.nvim" }, { "nvim-telescope/telescope.nvim" },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = { opts = {
ensure_installed = { "go" }, ensure_installed = { "go" },
}, },
}, },
}, },
build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional build = "go install github.com/lotusirous/gostdsym/stdsym@latest", -- optional
cmd = { "GoDoc" }, -- optional cmd = { "GoDoc" }, -- optional
opts = { opts = {
picker = { picker = {
type = "telescope", type = "telescope",
}, },
}, },
} }

View file

@ -1,18 +1,26 @@
return { return {
"ThePrimeagen/harpoon", "ThePrimeagen/harpoon",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
config = function() config = function()
local mark = require("harpoon.mark") local mark = require("harpoon.mark")
local ui = require("harpoon.ui") local ui = require("harpoon.ui")
vim.keymap.set("n", "<leader>a", mark.add_file) vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu) vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
vim.keymap.set("n", "<leader>q", function() ui.nav_file(1) end) vim.keymap.set("n", "<leader>q", function()
vim.keymap.set("n", "<leader>w", function() ui.nav_file(2) end) ui.nav_file(1)
vim.keymap.set("n", "<leader>e", function() ui.nav_file(3) end) end)
vim.keymap.set("n", "<leader>r", function() ui.nav_file(4) end) vim.keymap.set("n", "<leader>w", function()
vim.keymap.set("n", "<leader>,", ui.nav_prev) ui.nav_file(2)
vim.keymap.set("n", "<leader>.", ui.nav_next) end)
end vim.keymap.set("n", "<leader>e", function()
ui.nav_file(3)
end)
vim.keymap.set("n", "<leader>r", function()
ui.nav_file(4)
end)
vim.keymap.set("n", "<leader>,", ui.nav_prev)
vim.keymap.set("n", "<leader>.", ui.nav_next)
end,
} }

View file

@ -1,12 +1,12 @@
return { return {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
opts = { opts = {
indent = { indent = {
smart_indent_cap = true, smart_indent_cap = true,
},
scope = {
show_end = true,
},
}, },
main = "ibl" scope = {
show_end = true,
},
},
main = "ibl",
} }

View file

@ -1,9 +1,9 @@
return { return {
'folke/lazydev.nvim', "folke/lazydev.nvim",
ft = 'lua', ft = "lua",
opts = { opts = {
library = { library = {
{ path = 'luvit-meta/library', words = { 'vim%.uv' } }, { path = "luvit-meta/library", words = { "vim%.uv" } },
},
}, },
},
} }

View file

@ -1,154 +1,154 @@
return { return {
-- lspconfig -- lspconfig
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { dependencies = {
{ "williamboman/mason.nvim", opts = {} }, { "williamboman/mason.nvim", opts = {} },
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim", "WhoIsSethDaniel/mason-tool-installer.nvim",
-- status updates for LSP -- status updates for LSP
{ "j-hui/fidget.nvim", opts = {} }, { "j-hui/fidget.nvim", opts = {} },
{ "hrsh7th/cmp-nvim-lsp" }, -- Required { "hrsh7th/cmp-nvim-lsp" }, -- Required
}, },
config = function() config = function()
-- stole this from kickstart, great config -- stole this from kickstart, great config
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }), group = vim.api.nvim_create_augroup("kickstart-lsp-attach", { clear = true }),
callback = function(event) callback = function(event)
local map = function(keys, func, desc, mode) local map = function(keys, func, desc, mode)
mode = mode or "n" mode = mode or "n"
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc }) vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = "LSP: " .. desc })
end end
-- Jump to the definition of the word under your cursor. -- Jump to the definition of the word under your cursor.
-- This is where a variable was first declared, or where a function is defined, etc. -- This is where a variable was first declared, or where a function is defined, etc.
-- To jump back, press <C-t>. -- To jump back, press <C-t>.
map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition") map("gd", require("telescope.builtin").lsp_definitions, "[G]oto [D]efinition")
-- Find references for the word under your cursor. -- Find references for the word under your cursor.
map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences") map("gr", require("telescope.builtin").lsp_references, "[G]oto [R]eferences")
-- Jump to the implementation of the word under your cursor. -- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation. -- Useful when your language has ways of declaring types without an actual implementation.
map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation") map("gI", require("telescope.builtin").lsp_implementations, "[G]oto [I]mplementation")
-- Jump to the type of the word under your cursor. -- Jump to the type of the word under your cursor.
-- Useful when you're not sure what type a variable is and you want to see -- Useful when you're not sure what type a variable is and you want to see
-- the definition of its *type*, not where it was *defined*. -- the definition of its *type*, not where it was *defined*.
map("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition") map("<leader>D", require("telescope.builtin").lsp_type_definitions, "Type [D]efinition")
-- Fuzzy find all the symbols in your current document. -- Fuzzy find all the symbols in your current document.
-- Symbols are things like variables, functions, types, etc. -- Symbols are things like variables, functions, types, etc.
map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols") map("<leader>ds", require("telescope.builtin").lsp_document_symbols, "[D]ocument [S]ymbols")
-- Fuzzy find all the symbols in your current workspace. -- Fuzzy find all the symbols in your current workspace.
-- Similar to document symbols, except searches over your entire project. -- Similar to document symbols, except searches over your entire project.
map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols") map("<leader>ws", require("telescope.builtin").lsp_dynamic_workspace_symbols, "[W]orkspace [S]ymbols")
-- Rename the variable under your cursor. -- Rename the variable under your cursor.
-- Most Language Servers support renaming across files, etc. -- Most Language Servers support renaming across files, etc.
map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame") map("<leader>rn", vim.lsp.buf.rename, "[R]e[n]ame")
-- Execute a code action, usually your cursor needs to be on top of an error -- Execute a code action, usually your cursor needs to be on top of an error
-- or a suggestion from your LSP for this to activate. -- or a suggestion from your LSP for this to activate.
map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" }) map("<leader>ca", vim.lsp.buf.code_action, "[C]ode [A]ction", { "n", "x" })
-- WARN: This is not Goto Definition, this is Goto Declaration. -- WARN: This is not Goto Definition, this is Goto Declaration.
-- For example, in C this would take you to the header. -- For example, in C this would take you to the header.
map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration") map("gD", vim.lsp.buf.declaration, "[G]oto [D]eclaration")
map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic") map("[d", vim.diagnostic.goto_prev, "Go to previous diagnostic")
map("]d", vim.diagnostic.goto_next, "Go to next diagnostic") map("]d", vim.diagnostic.goto_next, "Go to next diagnostic")
-- The following two autocommands are used to highlight references of the -- The following two autocommands are used to highlight references of the
-- word under your cursor when your cursor rests there for a little while. -- word under your cursor when your cursor rests there for a little while.
-- See `:help CursorHold` for information about when this is executed -- See `:help CursorHold` for information about when this is executed
-- --
-- When you move your cursor, the highlights will be cleared (the second autocommand). -- When you move your cursor, the highlights will be cleared (the second autocommand).
local client = vim.lsp.get_client_by_id(event.data.client_id) local client = vim.lsp.get_client_by_id(event.data.client_id)
if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then if client and client.supports_method(vim.lsp.protocol.Methods.textDocument_documentHighlight) then
local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false }) local highlight_augroup = vim.api.nvim_create_augroup("kickstart-lsp-highlight", { clear = false })
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, { vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI" }, {
buffer = event.buf, buffer = event.buf,
group = highlight_augroup, group = highlight_augroup,
callback = vim.lsp.buf.document_highlight, callback = vim.lsp.buf.document_highlight,
}) })
vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, { vim.api.nvim_create_autocmd({ "CursorMoved", "CursorMovedI" }, {
buffer = event.buf, buffer = event.buf,
group = highlight_augroup, group = highlight_augroup,
callback = vim.lsp.buf.clear_references, callback = vim.lsp.buf.clear_references,
}) })
vim.api.nvim_create_autocmd("LspDetach", { vim.api.nvim_create_autocmd("LspDetach", {
group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }), group = vim.api.nvim_create_augroup("kickstart-lsp-detach", { clear = true }),
callback = function(event2) callback = function(event2)
vim.lsp.buf.clear_references() vim.lsp.buf.clear_references()
vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf }) vim.api.nvim_clear_autocmds({ group = "kickstart-lsp-highlight", buffer = event2.buf })
end, end,
}) })
end end
end, end,
}) })
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities())
vim.filetype.add({ vim.filetype.add({
extension = { extension = {
templ = "templ", templ = "templ",
}, },
}) })
local servers = { local servers = {
ts_ls = {}, ts_ls = {},
gopls = {}, gopls = {},
zls = {}, zls = {},
rust_analyzer = {}, rust_analyzer = {},
templ = { templ = {
filetypes = { "templ" }, filetypes = { "templ" },
}, },
intelephense = {}, intelephense = {},
lua_ls = { lua_ls = {
settings = { settings = {
Lua = { Lua = {
completion = { completion = {
callSnippet = "Replace", callSnippet = "Replace",
}, },
}, },
}, },
}, },
tailwindcss = { tailwindcss = {
filetypes = { filetypes = {
"templ", "templ",
"html", "html",
"javascript", "javascript",
"typescript", "typescript",
"javascriptreact", "javascriptreact",
"typescriptreact", "typescriptreact",
}, },
init_options = { init_options = {
userLanguages = { userLanguages = {
templ = "html", templ = "html",
}, },
}, },
}, },
} }
local ensure_installed = vim.tbl_keys(servers or {}) local ensure_installed = vim.tbl_keys(servers or {})
vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" }) vim.list_extend(ensure_installed, { "stylua", "yamlfmt", "autopep8", "biome", "goimports" })
require("mason-tool-installer").setup({ ensure_installed = ensure_installed }) require("mason-tool-installer").setup({ ensure_installed = ensure_installed })
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({
handlers = { handlers = {
function(server_name) function(server_name)
local server = servers[server_name] or {} local server = servers[server_name] or {}
server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {}) server.capabilities = vim.tbl_deep_extend("force", {}, capabilities, server.capabilities or {})
require("lspconfig")[server_name].setup(server) require("lspconfig")[server_name].setup(server)
end, end,
}, },
}) })
end, end,
} }

View file

@ -1,13 +1,13 @@
return { return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons", lazy = true }, dependencies = { "nvim-tree/nvim-web-devicons", lazy = true },
config = function() config = function()
local lualine = require('lualine') local lualine = require("lualine")
lualine.setup { lualine.setup({
options = { options = {
icons_enabled = false, icons_enabled = false,
--[[ section_separators = { --[[ section_separators = {
left = '', left = '',
right = '' right = ''
}, },
@ -15,44 +15,48 @@ return {
left = '', left = '',
right = '' right = ''
}, ]] }, ]]
section_separators = '', section_separators = "",
component_separators = '|', component_separators = "|",
disabled_filetypes = {} disabled_filetypes = {},
}, },
sections = { sections = {
lualine_a = { }, lualine_a = {},
lualine_b = { }, lualine_b = {},
lualine_c = { { lualine_c = {
'filename', {
file_status = true, -- display file status "filename",
path = 1 -- no file path file_status = true, -- display file status
} }, path = 1, -- no file path
lualine_x = { },
{ },
'diagnostics', lualine_x = {
sources = { 'nvim_diagnostic' }, {
symbols = { error = '', warn = '', info = '', hint = '' } "diagnostics",
}, sources = { "nvim_diagnostic" },
'enconding', symbols = { error = "", warn = "", info = "", hint = "" },
'filetype' },
}, "enconding",
lualine_y = { 'progress' }, "filetype",
lualine_z = { 'location' } },
}, lualine_y = { "progress" },
inactive_sections = { lualine_z = { "location" },
lualine_a = {}, },
lualine_b = {}, inactive_sections = {
lualine_c = { { lualine_a = {},
'filename', lualine_b = {},
file_status = true, lualine_c = {
path = 1 {
} }, "filename",
lualine_x = { 'location' }, file_status = true,
lualine_y = {}, path = 1,
lualine_z = {} },
}, },
tabline = {}, lualine_x = { "location" },
extensions = { 'fugitive' } lualine_y = {},
} lualine_z = {},
end },
tabline = {},
extensions = { "fugitive" },
})
end,
} }

View file

@ -1,4 +1,4 @@
return { return {
'Bilal2453/luvit-meta', "Bilal2453/luvit-meta",
lazy = true, lazy = true,
} }

View file

@ -1,71 +1,71 @@
return { return {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
enabled = false, enabled = false,
branch = "v2.x", branch = "v2.x",
cmd = { "Neotree" }, cmd = { "Neotree" },
keys = { keys = {
{ "<leader>fs", "<cmd>NeoTreeFloatToggle<CR>", desc = "Toggle [F]ile [S]ystem Floating Menu" }, { "<leader>fs", "<cmd>NeoTreeFloatToggle<CR>", desc = "Toggle [F]ile [S]ystem Floating Menu" },
{ "<C-b>", "<cmd>NeoTreeFocusToggle<CR>", desc = "Open Side File System" } { "<C-b>", "<cmd>NeoTreeFocusToggle<CR>", desc = "Open Side File System" },
},
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
opts = {
use_default_mappings = true,
mappings = {
["<space>"] = {
"toggle_node",
nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use
},
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["<esc>"] = "cancel", -- close preview or floating neo-tree window
["P"] = { "toggle_preview", config = { use_float = true } },
["l"] = "focus_preview",
["O"] = "open_split",
["o"] = "open_vsplit",
["S"] = "none",
["s"] = "none",
-- ["S"] = "split_with_window_picker",
-- ["s"] = "vsplit_with_window_picker",
["t"] = "open_tabnew",
-- ["<cr>"] = "open_drop",
-- ["t"] = "open_tab_drop",
["w"] = "open_with_window_picker",
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
["C"] = "close_node",
-- ['C'] = 'close_all_subnodes',
["z"] = "close_all_nodes",
--["Z"] = "expand_all_nodes",
["a"] = {
"add",
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none", -- "none", "relative", "absolute"
},
},
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
["d"] = "delete",
["r"] = "rename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
-- ["c"] = {
-- "copy",
-- config = {
-- show_path = "none" -- "none", "relative", "absolute"
-- }
--}
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
["q"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
}, },
dependencies = { },
"nvim-lua/plenary.nvim",
"nvim-tree/nvim-web-devicons",
"MunifTanjim/nui.nvim",
},
opts = {
use_default_mappings = true,
mappings = {
["<space>"] = {
"toggle_node",
nowait = true, -- disable `nowait` if you have existing combos starting with this char that you want to use
},
["<2-LeftMouse>"] = "open",
["<cr>"] = "open",
["<esc>"] = "cancel", -- close preview or floating neo-tree window
["P"] = { "toggle_preview", config = { use_float = true } },
["l"] = "focus_preview",
["O"] = "open_split",
["o"] = "open_vsplit",
["S"] = "none",
["s"] = "none",
-- ["S"] = "split_with_window_picker",
-- ["s"] = "vsplit_with_window_picker",
["t"] = "open_tabnew",
-- ["<cr>"] = "open_drop",
-- ["t"] = "open_tab_drop",
["w"] = "open_with_window_picker",
--["P"] = "toggle_preview", -- enter preview mode, which shows the current node without focusing
["C"] = "close_node",
-- ['C'] = 'close_all_subnodes',
["z"] = "close_all_nodes",
--["Z"] = "expand_all_nodes",
["a"] = {
"add",
-- this command supports BASH style brace expansion ("x{a,b,c}" -> xa,xb,xc). see `:h neo-tree-file-actions` for details
-- some commands may take optional config options, see `:h neo-tree-mappings` for details
config = {
show_path = "none" -- "none", "relative", "absolute"
}
},
["A"] = "add_directory", -- also accepts the optional config.show_path option like "add". this also supports BASH style brace expansion.
["d"] = "delete",
["r"] = "rename",
["y"] = "copy_to_clipboard",
["x"] = "cut_to_clipboard",
["p"] = "paste_from_clipboard",
["c"] = "copy", -- takes text input for destination, also accepts the optional config.show_path option like "add":
-- ["c"] = {
-- "copy",
-- config = {
-- show_path = "none" -- "none", "relative", "absolute"
-- }
--}
["m"] = "move", -- takes text input for destination, also accepts the optional config.show_path option like "add".
["q"] = "close_window",
["R"] = "refresh",
["?"] = "show_help",
["<"] = "prev_source",
[">"] = "next_source",
}
}
} }

View file

@ -1,84 +1,84 @@
local linters_by_ft = { local linters_by_ft = {
javascript = { "biomejs", "eslint" }, javascript = { "biomejs", "eslint" },
typescript = { "biomejs", "eslint" }, typescript = { "biomejs", "eslint" },
javascriptreact = { "biomejs", "eslint" }, javascriptreact = { "biomejs", "eslint" },
typescriptreact = { "biomejs", "eslint" }, typescriptreact = { "biomejs", "eslint" },
jsonc = { "biomejs" }, jsonc = { "biomejs" },
json = { "biomejs" }, json = { "biomejs" },
css = { "biomejs" }, css = { "biomejs" },
} }
-- Function to find the first config file by walking up the directory tree -- Function to find the first config file by walking up the directory tree
local function find_first_config() local function find_first_config()
local current_dir = vim.fn.expand("%:p:h") local current_dir = vim.fn.expand("%:p:h")
local home_dir = vim.fn.expand("$HOME") local home_dir = vim.fn.expand("$HOME")
local config_files = { local config_files = {
biomejs = { "biome.json" }, biomejs = { "biome.json" },
eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" }, eslint = { ".eslintrc", ".eslintrc.js", ".eslintrc.json", ".eslintrc.yml" },
} }
while current_dir ~= home_dir and current_dir ~= "/" do while current_dir ~= home_dir and current_dir ~= "/" do
for linter, patterns in pairs(config_files) do for linter, patterns in pairs(config_files) do
for _, pattern in ipairs(patterns) do for _, pattern in ipairs(patterns) do
local config_file = current_dir .. "/" .. pattern local config_file = current_dir .. "/" .. pattern
if vim.fn.filereadable(config_file) == 1 then if vim.fn.filereadable(config_file) == 1 then
return linter return linter
end end
end end
end end
current_dir = vim.fn.fnamemodify(current_dir, ":h") current_dir = vim.fn.fnamemodify(current_dir, ":h")
end end
return nil return nil
end end
-- Function to determine the linter based on config files and file type -- Function to determine the linter based on config files and file type
local function get_linter() local function get_linter()
local filetype = vim.bo.filetype local filetype = vim.bo.filetype
local available_linters = linters_by_ft[filetype] or {} local available_linters = linters_by_ft[filetype] or {}
local linter = find_first_config() local linter = find_first_config()
if linter then if linter then
if vim.tbl_contains(available_linters, linter) then if vim.tbl_contains(available_linters, linter) then
vim.g.current_linter = linter vim.g.current_linter = linter
return linter return linter
end end
end end
return nil return nil
end end
local function lint() local function lint()
local nvimlint = require("lint") local nvimlint = require("lint")
local linter = get_linter() local linter = get_linter()
if linter ~= nil then if linter ~= nil then
nvimlint.try_lint(linter) nvimlint.try_lint(linter)
else else
print("No linter found for filetype: " .. vim.bo.filetype) print("No linter found for filetype: " .. vim.bo.filetype)
end end
end end
return { return {
"mfussenegger/nvim-lint", "mfussenegger/nvim-lint",
keys = { keys = {
{ {
"<leader>lf", "<leader>lf",
function() function()
lint() lint()
end, end,
mode = "n", mode = "n",
desc = "[L]int [F]ile", desc = "[L]int [F]ile",
}, },
}, },
config = function() config = function()
vim.api.nvim_create_user_command("Lint", function() vim.api.nvim_create_user_command("Lint", function()
lint() lint()
end, { desc = "Lint file" }) end, { desc = "Lint file" })
vim.api.nvim_create_user_command("LintInfo", function() vim.api.nvim_create_user_command("LintInfo", function()
print("Current linter: " .. (vim.g.current_linter or "none")) print("Current linter: " .. (vim.g.current_linter or "none"))
end, { end, {
desc = "Show current linter being used", desc = "Show current linter being used",
}) })
end, end,
} }

View file

@ -1,28 +1,28 @@
return { return {
"stevearc/oil.nvim", "stevearc/oil.nvim",
---@module 'oil' ---@module 'oil'
---@type oil.SetupOpts ---@type oil.SetupOpts
-- Optional dependencies -- Optional dependencies
dependencies = { { "echasnovski/mini.icons", opts = {} } }, dependencies = { { "echasnovski/mini.icons", opts = {} } },
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations. -- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false, lazy = false,
config = function() config = function()
local oil = require("oil") local oil = require("oil")
oil.setup({ oil.setup({
view_options = { view_options = {
show_hidden = true, show_hidden = true,
}, },
}) })
end, end,
keys = { keys = {
{ {
"<leader>oo", "<leader>oo",
function() function()
require("oil").open() require("oil").open()
end, end,
mode = "n", mode = "n",
desc = "[O]pen [O]il", desc = "[O]pen [O]il",
}, },
}, },
} }

View file

@ -1,9 +1,9 @@
return { return {
"MeanderingProgrammer/render-markdown.nvim", "MeanderingProgrammer/render-markdown.nvim",
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins
-- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons
---@module 'render-markdown' ---@module 'render-markdown'
---@type render.md.UserConfig ---@type render.md.UserConfig
opts = {}, opts = {},
} }

View file

@ -1,181 +1,181 @@
local function get_fd_command() local function get_fd_command()
if vim.fn.executable("fd") == 1 then if vim.fn.executable("fd") == 1 then
return "fd" return "fd"
elseif vim.fn.executable("fdfind") == 1 then elseif vim.fn.executable("fdfind") == 1 then
return "fdfind" return "fdfind"
end end
return nil return nil
end end
return { return {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
version = "0.1.8", version = "0.1.8",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
{ {
"nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-fzf-native.nvim",
build = "make", build = "make",
enabled = true, enabled = true,
cond = function() cond = function()
return vim.fn.executable("make") == 1 return vim.fn.executable("make") == 1
end, end,
}, },
{ {
"nvim-telescope/telescope-file-browser.nvim", "nvim-telescope/telescope-file-browser.nvim",
dependencies = { dependencies = {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
}, },
enabled = true, enabled = true,
}, },
{ "nvim-telescope/telescope-ui-select.nvim" }, { "nvim-telescope/telescope-ui-select.nvim" },
{ "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font }, { "nvim-tree/nvim-web-devicons", enabled = vim.g.have_nerd_font },
}, },
config = function() config = function()
local telescope = require("telescope") local telescope = require("telescope")
local actions = require("telescope.actions") local actions = require("telescope.actions")
local builtin = require("telescope.builtin") local builtin = require("telescope.builtin")
local fb_actions = require("telescope").extensions.file_browser.actions local fb_actions = require("telescope").extensions.file_browser.actions
local function telescope_buffer_dir() local function telescope_buffer_dir()
return vim.fn.expand("%:p:h") return vim.fn.expand("%:p:h")
end end
telescope.setup({ telescope.setup({
defaults = { defaults = {
mappings = { mappings = {
n = { n = {
["q"] = actions.close, ["q"] = actions.close,
}, },
}, },
}, },
extensions = { extensions = {
["ui-select"] = { ["ui-select"] = {
require("telescope.themes").get_dropdown(), require("telescope.themes").get_dropdown(),
}, },
file_browser = { file_browser = {
theme = "dropdown", theme = "dropdown",
hijack_netrw = false, hijack_netrw = false,
hidden = true, hidden = true,
mappings = { mappings = {
["i"] = { ["i"] = {
["<C-w>"] = function() ["<C-w>"] = function()
vim.cmd("normal vbd") vim.cmd("normal vbd")
end, end,
["<C-j>"] = function(bufnr) ["<C-j>"] = function(bufnr)
actions.move_selection_next(bufnr) actions.move_selection_next(bufnr)
end, end,
["<C-k>"] = function(bufnr) ["<C-k>"] = function(bufnr)
actions.move_selection_previous(bufnr) actions.move_selection_previous(bufnr)
end, end,
["<C-s>"] = function(bufnr) ["<C-s>"] = function(bufnr)
actions.select_vertical(bufnr) actions.select_vertical(bufnr)
end, end,
}, },
["n"] = { ["n"] = {
["a"] = fb_actions.create, ["a"] = fb_actions.create,
["h"] = fb_actions.goto_parent_dir, ["h"] = fb_actions.goto_parent_dir,
["/"] = function() ["/"] = function()
vim.cmd("startinsert") vim.cmd("startinsert")
end, end,
["d"] = fb_actions.remove, ["d"] = fb_actions.remove,
["e"] = fb_actions.change_cwd, ["e"] = fb_actions.change_cwd,
["<C-s>"] = function(bufnr) ["<C-s>"] = function(bufnr)
actions.select_vertical(bufnr) actions.select_vertical(bufnr)
end, end,
["<C-a>"] = function(bufnr) ["<C-a>"] = function(bufnr)
actions.toggle_all(bufnr) actions.toggle_all(bufnr)
end, end,
["<C-d>"] = function(bufnr) ["<C-d>"] = function(bufnr)
actions.move_selection_next(bufnr) actions.move_selection_next(bufnr)
end, end,
["<C-u>"] = function(bufnr) ["<C-u>"] = function(bufnr)
actions.move_selection_previous(bufnr) actions.move_selection_previous(bufnr)
end, end,
}, },
}, },
}, },
}, },
}) })
pcall(telescope.load_extension, "file_browser") pcall(telescope.load_extension, "file_browser")
pcall(telescope.load_extension, "fzf") pcall(telescope.load_extension, "fzf")
pcall(telescope.load_extension, "ui-select") pcall(telescope.load_extension, "ui-select")
-- Builtin pickers -- Builtin pickers
vim.keymap.set("n", "<leader>sf", function() vim.keymap.set("n", "<leader>sf", function()
local fd_cmd = get_fd_command() local fd_cmd = get_fd_command()
local config = { local config = {
hidden = true, hidden = true,
file_ignore_patterns = { file_ignore_patterns = {
"node%_modules/.*", "node%_modules/.*",
"%.git/.*", "%.git/.*",
}, },
} }
if fd_cmd then if fd_cmd then
config.find_command = { config.find_command = {
fd_cmd, fd_cmd,
"--type", "--type",
"f", "f",
"--color", "--color",
"never", "never",
"--hidden", "--hidden",
"--no-ignore", "--no-ignore",
} }
end end
builtin.find_files(config) builtin.find_files(config)
end, { desc = "[S]earch [F]iles" }) end, { desc = "[S]earch [F]iles" })
vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" }) vim.keymap.set("n", "<leader>sh", builtin.help_tags, { desc = "[S]earch [H]elp Tags" })
vim.keymap.set("n", "<leader>sb", builtin.buffers, { desc = "[S]earch [B]uffers" }) vim.keymap.set("n", "<leader>sb", builtin.buffers, { desc = "[S]earch [B]uffers" })
vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" }) vim.keymap.set("n", "<leader>sw", builtin.grep_string, { desc = "[S]earch current [W]ord" })
vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" }) vim.keymap.set("n", "<leader>sg", builtin.live_grep, { desc = "[S]earch by [G]rep" })
vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" }) vim.keymap.set("n", "<leader>sd", builtin.diagnostics, { desc = "[S]earch [D]iagnostics" })
vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true }) vim.keymap.set("n", "gr", builtin.lsp_references, { desc = "[G]o to [R]eferences", noremap = true })
vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" }) vim.keymap.set("n", "gd", builtin.lsp_definitions, { desc = "[G]o to [D]efinitions" })
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" }) vim.keymap.set("n", "gD", vim.lsp.buf.declaration, { desc = "[G]o to [D]eclaration" })
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" }) vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, { desc = "[R]e[N]ame" })
-- Git pickers -- Git pickers
vim.keymap.set("n", "<leader>gf", builtin.git_files, { desc = "Search [G]it [F]iles" }) vim.keymap.set("n", "<leader>gf", builtin.git_files, { desc = "Search [G]it [F]iles" })
vim.keymap.set("n", "<leader>gs", builtin.git_status, { desc = "List [G]it [S]tatus" }) vim.keymap.set("n", "<leader>gs", builtin.git_status, { desc = "List [G]it [S]tatus" })
vim.keymap.set("n", "<leader>gh", builtin.git_stash, { desc = "List [G]it [S]tash" }) vim.keymap.set("n", "<leader>gh", builtin.git_stash, { desc = "List [G]it [S]tash" })
vim.keymap.set("n", "<leader>gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" }) vim.keymap.set("n", "<leader>gbb", builtin.git_branches, { desc = "List [G]it [B]ranches" })
vim.keymap.set("n", "<leader>gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" }) vim.keymap.set("n", "<leader>gc", builtin.git_bcommits, { desc = "List Buffer [G]it [C]ommits" })
-- File Browser Ext -- File Browser Ext
vim.keymap.set("n", "<leader>fs", function() vim.keymap.set("n", "<leader>fs", function()
telescope.extensions.file_browser.file_browser({ telescope.extensions.file_browser.file_browser({
path = "%:p:h", path = "%:p:h",
cwd = telescope_buffer_dir(), cwd = telescope_buffer_dir(),
respect_gitignore = false, respect_gitignore = false,
hidden = true, hidden = true,
grouped = true, grouped = true,
previewer = false, previewer = false,
initial_mode = "normal", initial_mode = "normal",
layout_config = { height = 40 }, layout_config = { height = 40 },
}) })
end, { desc = "Open [F]ile [S]ystem Menu" }) end, { desc = "Open [F]ile [S]ystem Menu" })
vim.keymap.set("n", "<leader>/", function() vim.keymap.set("n", "<leader>/", function()
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({ builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
winblend = 10, winblend = 10,
previewer = false, previewer = false,
})) }))
end, { desc = "[/] Fuzzily serach in current buffer" }) end, { desc = "[/] Fuzzily serach in current buffer" })
-- live grep in open files only -- live grep in open files only
vim.keymap.set("n", "<leader>s/", function() vim.keymap.set("n", "<leader>s/", function()
builtin.live_grep({ builtin.live_grep({
grep_open_files = true, grep_open_files = true,
prompt_title = "Live Grep in Open Files", prompt_title = "Live Grep in Open Files",
}) })
end, { desc = "[S]search [/] in Open Files" }) end, { desc = "[S]search [/] in Open Files" })
-- shortcut for searching neovim config files -- shortcut for searching neovim config files
vim.keymap.set("n", "<leader>sn", function() vim.keymap.set("n", "<leader>sn", function()
builtin.find_files({ cwd = vim.fn.stdpath("config") }) builtin.find_files({ cwd = vim.fn.stdpath("config") })
end, { desc = "[S]earch [N]eovim files" }) end, { desc = "[S]earch [N]eovim files" })
end, end,
} }

View file

@ -1,5 +1,5 @@
return { return {
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
opts = {}, opts = {},
} }

View file

@ -1,47 +1,51 @@
return { return {
"akinsho/toggleterm.nvim", "akinsho/toggleterm.nvim",
version = "*", version = "*",
keys = { keys = {
{ "<leader>lg", function() {
local Terminal = require('toggleterm.terminal').Terminal "<leader>lg",
local lazygit = Terminal:new({ function()
cmd = "lazygit", local Terminal = require("toggleterm.terminal").Terminal
direction = "float", local lazygit = Terminal:new({
float_opts = { cmd = "lazygit",
border = "double", direction = "float",
}, float_opts = {
on_open = function(term) border = "double",
vim.cmd("startinsert!") },
end, on_open = function(term)
on_close = function(term) vim.cmd("startinsert!")
vim.cmd("startinsert!") end,
end, on_close = function(term)
}) vim.cmd("startinsert!")
lazygit:toggle() end,
end, desc = "Open lazygit in a floating window" }, })
lazygit:toggle()
end,
desc = "Open lazygit in a floating window",
}, },
opts = { },
size = 20, opts = {
open_mapping = [[<c-\>]], size = 20,
hide_numbers = true, open_mapping = [[<c-\>]],
shade_filetypes = {}, hide_numbers = true,
shade_terminals = true, shade_filetypes = {},
shading_factor = 2, shade_terminals = true,
start_in_insert = true, shading_factor = 2,
insert_mappings = true, start_in_insert = true,
terminal_mappings = true, insert_mappings = true,
persist_size = true, terminal_mappings = true,
persist_mode = true, persist_size = true,
direction = "float", persist_mode = true,
close_on_exit = true, direction = "float",
shell = vim.o.shell, close_on_exit = true,
float_opts = { shell = vim.o.shell,
border = "curved", float_opts = {
winblend = 0, border = "curved",
highlights = { winblend = 0,
border = "Normal", highlights = {
background = "Normal", border = "Normal",
}, background = "Normal",
}, },
}, },
},
} }

View file

@ -1,100 +1,100 @@
return { return {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
build = ":TSUpdate", build = ":TSUpdate",
event = { event = {
"BufReadPost", "BufReadPost",
"BufNewFile", "BufNewFile",
}, },
branch = "master", branch = "master",
dependencies = { dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter/nvim-treesitter-textobjects",
}, },
config = function() config = function()
local treesitter = require("nvim-treesitter.configs") local treesitter = require("nvim-treesitter.configs")
treesitter.setup({ treesitter.setup({
-- A list of parser names, or "all" -- A list of parser names, or "all"
ensure_installed = { ensure_installed = {
"vimdoc", "vimdoc",
"javascript", "javascript",
"typescript", "typescript",
"c", "c",
"lua", "lua",
"rust", "rust",
"go", "go",
"gosum", "gosum",
"gomod", "gomod",
"php", "php",
"blade", "blade",
}, },
-- Install parsers synchronously (only applied to `ensure_installed`) -- Install parsers synchronously (only applied to `ensure_installed`)
sync_install = false, sync_install = false,
-- Automatically install missing parsers when entering buffer -- Automatically install missing parsers when entering buffer
auto_install = true, auto_install = true,
indent = { indent = {
enable = true, enable = true,
}, },
highlight = { highlight = {
enable = true, enable = true,
additional_vim_regex_highlighting = true, additional_vim_regex_highlighting = true,
}, },
incremental_selection = { incremental_selection = {
enable = true, enable = true,
keymaps = { keymaps = {
init_selection = "<leader>c", init_selection = "<leader>c",
node_incremental = "<C-p>", node_incremental = "<C-p>",
scope_incremental = "<C-s>", scope_incremental = "<C-s>",
node_decremental = "<M-p>", node_decremental = "<M-p>",
}, },
}, },
textobjects = { textobjects = {
select = { select = {
enable = true, enable = true,
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
keymaps = { keymaps = {
-- You can use the capture groups defined in textobjects.scm -- You can use the capture groups defined in textobjects.scm
["aa"] = "@parameter.outer", ["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner", ["ia"] = "@parameter.inner",
["af"] = "@function.outer", ["af"] = "@function.outer",
["if"] = "@function.inner", ["if"] = "@function.inner",
["ac"] = "@class.outer", ["ac"] = "@class.outer",
["ic"] = "@class.inner", ["ic"] = "@class.inner",
}, },
}, },
move = { move = {
enable = true, enable = true,
set_jumps = true, -- whether to set jumps in the jumplist set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = { goto_next_start = {
["]m"] = "@function.outer", ["]m"] = "@function.outer",
["]]"] = "@class.outer", ["]]"] = "@class.outer",
}, },
goto_next_end = { goto_next_end = {
["]M"] = "@function.outer", ["]M"] = "@function.outer",
["]["] = "@class.outer", ["]["] = "@class.outer",
}, },
goto_previous_start = { goto_previous_start = {
["[m"] = "@function.outer", ["[m"] = "@function.outer",
["[["] = "@class.outer", ["[["] = "@class.outer",
}, },
goto_previous_end = { goto_previous_end = {
["[M"] = "@function.outer", ["[M"] = "@function.outer",
["[]"] = "@class.outer", ["[]"] = "@class.outer",
}, },
}, },
swap = { swap = {
enable = true, enable = true,
swap_next = { swap_next = {
["<leader>]"] = "@parameter.inner", ["<leader>]"] = "@parameter.inner",
}, },
swap_previous = { swap_previous = {
["<leader>["] = "@parameter.inner", ["<leader>["] = "@parameter.inner",
}, },
}, },
}, },
autotag = { autotag = {
enable = false, enable = false,
enable_close_on_slash = false, enable_close_on_slash = false,
}, },
}) })
end, end,
} }

View file

@ -1,22 +1,22 @@
return { return {
"mbbill/undotree", "mbbill/undotree",
keys = { keys = {
{ "<leader>u", "<cmd>UndotreeToggle<CR>", desc = "Toggle Undotree" }, { "<leader>u", "<cmd>UndotreeToggle<CR>", desc = "Toggle Undotree" },
}, },
config = function() config = function()
local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" }) local has_persistent_undo = vim.api.nvim_call_function("has", { "persistent_undo" })
if has_persistent_undo then if has_persistent_undo then
local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" }) local target_path = vim.api.nvim_call_function("expand", { "~/.undodir" })
local is_directory = vim.api.nvim_call_function("isdirectory", { target_path }) local is_directory = vim.api.nvim_call_function("isdirectory", { target_path })
if not is_directory then if not is_directory then
vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 }) vim.api.nvim_call_function("mkdir", { target_path, "p", 0700 })
end end
vim.opt.undodir = target_path vim.opt.undodir = target_path
vim.opt.undofile = true vim.opt.undofile = true
end
end end
end,
} }

View file

@ -1,49 +1,49 @@
return { return {
{ {
"folke/which-key.nvim", "folke/which-key.nvim",
event = "VeryLazy", event = "VeryLazy",
config = function() config = function()
vim.opt.timeout = true vim.opt.timeout = true
vim.opt.timeoutlen = 300 vim.opt.timeoutlen = 300
local wk = require("which-key") local wk = require("which-key")
wk.setup({ wk.setup({
delay = 0, delay = 0,
icons = { icons = {
mappings = vim.g.have_nerd_font, mappings = vim.g.have_nerd_font,
keys = vim.g.have_nerd_font and {} or { keys = vim.g.have_nerd_font and {} or {
Up = '<Up> ', Up = "<Up> ",
Down = '<Down> ', Down = "<Down> ",
Left = '<Left> ', Left = "<Left> ",
Right = '<Right> ', Right = "<Right> ",
C = '<C-…> ', C = "<C-…> ",
M = '<M-…> ', M = "<M-…> ",
D = '<D-…> ', D = "<D-…> ",
S = '<S-…> ', S = "<S-…> ",
CR = '<CR> ', CR = "<CR> ",
Esc = '<Esc> ', Esc = "<Esc> ",
ScrollWheelDown = '<ScrollWheelDown> ', ScrollWheelDown = "<ScrollWheelDown> ",
ScrollWheelUp = '<ScrollWheelUp> ', ScrollWheelUp = "<ScrollWheelUp> ",
NL = '<NL> ', NL = "<NL> ",
BS = '<BS> ', BS = "<BS> ",
Space = '<Space> ', Space = "<Space> ",
Tab = '<Tab> ', Tab = "<Tab> ",
F1 = '<F1>', F1 = "<F1>",
F2 = '<F2>', F2 = "<F2>",
F3 = '<F3>', F3 = "<F3>",
F4 = '<F4>', F4 = "<F4>",
F5 = '<F5>', F5 = "<F5>",
F6 = '<F6>', F6 = "<F6>",
F7 = '<F7>', F7 = "<F7>",
F8 = '<F8>', F8 = "<F8>",
F9 = '<F9>', F9 = "<F9>",
F10 = '<F10>', F10 = "<F10>",
F11 = '<F11>', F11 = "<F11>",
F12 = '<F12>', F12 = "<F12>",
} },
} },
}) })
end, end,
} },
} }

View file

@ -5,33 +5,33 @@ local dark = "catppuccin-mocha"
---@return boolean ---@return boolean
function M.is_daytime() function M.is_daytime()
return false return false
end end
---@return boolean ---@return boolean
function M.legacy_is_daytime() function M.legacy_is_daytime()
return false return false
end end
---@return string ---@return string
function M.get_timebased_colorscheme() function M.get_timebased_colorscheme()
if M.is_daytime() then if M.is_daytime() then
vim.g.is_light_colors = true vim.g.is_light_colors = true
return light return light
else else
vim.g.is_light_colors = false vim.g.is_light_colors = false
return dark return dark
end end
end end
function M.toggle_colors() function M.toggle_colors()
if vim.g.is_light_colors then if vim.g.is_light_colors then
vim.g.is_light_colors = false vim.g.is_light_colors = false
vim.cmd.colorscheme(dark) vim.cmd.colorscheme(dark)
else else
vim.g.is_light_colors = true vim.g.is_light_colors = true
vim.cmd.colorscheme(light) vim.cmd.colorscheme(light)
end end
end end
return M return M

View file

@ -2,10 +2,10 @@
---@field os juancwu.utils.os ---@field os juancwu.utils.os
---@field colors juancwu.utils.colors ---@field colors juancwu.utils.colors
local M = setmetatable({}, { local M = setmetatable({}, {
__index = function(t, k) __index = function(t, k)
t[k] = require("juancwu.utils." .. k) t[k] = require("juancwu.utils." .. k)
return t[k] return t[k]
end, end,
}) })
return M return M

View file

@ -3,35 +3,35 @@ local M = {}
---@return boolean ---@return boolean
function M.is_linux() function M.is_linux()
return vim.loop.os_uname().sysname:find("Linux") ~= nil return vim.loop.os_uname().sysname:find("Linux") ~= nil
end end
---@return boolean ---@return boolean
function M.is_mac() function M.is_mac()
return vim.loop.os_uname().sysname:find("Darwin") ~= nil return vim.loop.os_uname().sysname:find("Darwin") ~= nil
end end
---@return boolean ---@return boolean
function M.is_win() function M.is_win()
return vim.loop.os_uname().sysname:find("Windows") ~= nil return vim.loop.os_uname().sysname:find("Windows") ~= nil
end end
---@return boolean ---@return boolean
function M.is_wsl() function M.is_wsl()
return vim.fn.has("wsl") == 1 return vim.fn.has("wsl") == 1
end end
---@param cmd string ---@param cmd string
---@return boolean ---@return boolean
function M.cmd_exists(cmd) function M.cmd_exists(cmd)
local handle = io.popen("command -v " .. cmd) local handle = io.popen("command -v " .. cmd)
if handle ~= nil then if handle ~= nil then
local result = handle:read("*a") local result = handle:read("*a")
handle:close() handle:close()
return #result > 0 return #result > 0
else else
return false return false
end end
end end
return M return M