From f9f53656f7a79625e667e46448b5f91b4b241682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A1bio=20Andr=C3=A9=20Damas?= Date: Thu, 27 Mar 2025 08:18:20 +0000 Subject: [PATCH] initial import --- .editorconfig | 12 ++ init.lua | 1 + lazy-lock.json | 28 +++ lsp/eslint.lua | 4 + lsp/gopls.lua | 4 + lsp/lemminx.lua | 4 + lsp/lua_ls.lua | 4 + lsp/pyright.lua | 14 ++ lsp/ruff.lua | 4 + lsp/tailwindcss.lua | 26 +++ lsp/vtsls.lua | 4 + lua/config/init.lua | 2 + lua/config/lazy.lua | 24 +++ lua/config/settings.lua | 61 +++++++ lua/plugins/blink.lua | 21 +++ lua/plugins/commander.lua | 154 ++++++++++++++++ lua/plugins/flash.nvim.lua | 5 + lua/plugins/fzf-lua.lua | 14 ++ lua/plugins/glance.lua | 50 ++++++ lua/plugins/hurl.nvim.lua | 86 +++++++++ lua/plugins/lsp.lua | 86 +++++++++ lua/plugins/lspsaga.nvim.lua | 44 +++++ lua/plugins/mini.files.lua | 3 + lua/plugins/mini.statusline.lua | 3 + lua/plugins/namu.nvim.lua | 24 +++ lua/plugins/neo-tree.nvim.lua | 18 ++ lua/plugins/nvim-autopairs.lua | 7 + lua/plugins/snacks.nvim.lua | 14 ++ lua/plugins/tokyonight.lua | 9 + lua/plugins/treesitter.lua | 32 ++++ lua/plugins/vim-fugitive.lua | 1 + lua/plugins/which-key.nvim.lua | 301 ++++++++++++++++++++++++++++++++ 32 files changed, 1064 insertions(+) create mode 100644 .editorconfig create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lsp/eslint.lua create mode 100644 lsp/gopls.lua create mode 100644 lsp/lemminx.lua create mode 100644 lsp/lua_ls.lua create mode 100644 lsp/pyright.lua create mode 100644 lsp/ruff.lua create mode 100644 lsp/tailwindcss.lua create mode 100644 lsp/vtsls.lua create mode 100644 lua/config/init.lua create mode 100644 lua/config/lazy.lua create mode 100644 lua/config/settings.lua create mode 100644 lua/plugins/blink.lua create mode 100644 lua/plugins/commander.lua create mode 100644 lua/plugins/flash.nvim.lua create mode 100644 lua/plugins/fzf-lua.lua create mode 100644 lua/plugins/glance.lua create mode 100644 lua/plugins/hurl.nvim.lua create mode 100644 lua/plugins/lsp.lua create mode 100644 lua/plugins/lspsaga.nvim.lua create mode 100644 lua/plugins/mini.files.lua create mode 100644 lua/plugins/mini.statusline.lua create mode 100644 lua/plugins/namu.nvim.lua create mode 100644 lua/plugins/neo-tree.nvim.lua create mode 100644 lua/plugins/nvim-autopairs.lua create mode 100644 lua/plugins/snacks.nvim.lua create mode 100644 lua/plugins/tokyonight.lua create mode 100644 lua/plugins/treesitter.lua create mode 100644 lua/plugins/vim-fugitive.lua create mode 100644 lua/plugins/which-key.nvim.lua diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9df6296 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 4 +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.lua] +max_line_length = 120 +align_array_table = false diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..dbc863e --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("config") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..e07a2a2 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,28 @@ +{ + "blink.cmp": { "branch": "main", "commit": "49f211fe5d729df53df4c042d7c3464cf47d199e" }, + "commander.nvim": { "branch": "main", "commit": "84101e8eb1613a72bbdec655b734f891d8a00694" }, + "flash.nvim": { "branch": "main", "commit": "3c942666f115e2811e959eabbdd361a025db8b63" }, + "friendly-snippets": { "branch": "main", "commit": "efff286dd74c22f731cdec26a70b46e5b203c619" }, + "fzf-lua": { "branch": "main", "commit": "ac6a34ea39831ec71c14f72075facf377ea9a00d" }, + "glance.nvim": { "branch": "master", "commit": "cb19b86349cbe634eec0ea768b9a27fdd6d24f34" }, + "hurl.nvim": { "branch": "main", "commit": "bf00b4ee56dc8026dd7cd068236fb2c01bb1e307" }, + "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" }, + "lspsaga.nvim": { "branch": "main", "commit": "778d56ff9b387dacd14ae648ed5604394b486f51" }, + "mason.nvim": { "branch": "main", "commit": "fc98833b6da5de5a9c5b1446ac541577059555be" }, + "mini.files": { "branch": "main", "commit": "01001e0cfc1e79f581d055ae3f70fbac96a2f378" }, + "mini.statusline": { "branch": "main", "commit": "1b0edf76fe2af015f8c989385ff949f1db7aade2" }, + "namu.nvim": { "branch": "main", "commit": "fc9632d7deb81c737577ecfa5879aa3bd1fc0433" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "9b5d67119c46e3262ffe1508fe6d8540b79ad75d" }, + "none-ls.nvim": { "branch": "main", "commit": "a117163db44c256d53c3be8717f3e1a2a28e6299" }, + "nui.nvim": { "branch": "main", "commit": "8d3bce9764e627b62b07424e0df77f680d47ffdb" }, + "nvim-autopairs": { "branch": "master", "commit": "6522027785b305269fa17088395dfc0f456cedd2" }, + "nvim-treesitter": { "branch": "master", "commit": "85168f15808d89b0222313652b9d2777eda3cb08" }, + "nvim-web-devicons": { "branch": "master", "commit": "4c3a5848ee0b09ecdea73adcd2a689190aeb728c" }, + "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, + "render-markdown.nvim": { "branch": "main", "commit": "84d413b0c432adaeaf3dcaac646638bd99d06aa6" }, + "snacks.nvim": { "branch": "main", "commit": "bc0630e43be5699bb94dadc302c0d21615421d93" }, + "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }, + "tokyonight.nvim": { "branch": "main", "commit": "057ef5d260c1931f1dffd0f052c685dcd14100a3" }, + "vim-fugitive": { "branch": "master", "commit": "4a745ea72fa93bb15dd077109afbb3d1809383f2" }, + "which-key.nvim": { "branch": "main", "commit": "370ec46f710e058c9c1646273e6b225acf47cbed" } +} diff --git a/lsp/eslint.lua b/lsp/eslint.lua new file mode 100644 index 0000000..2a73ce4 --- /dev/null +++ b/lsp/eslint.lua @@ -0,0 +1,4 @@ +return { + cmd = { "vscode-eslint-language-server", "--stdio" }, + filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx", "vue", "svelte", "astro" } +} diff --git a/lsp/gopls.lua b/lsp/gopls.lua new file mode 100644 index 0000000..39185f6 --- /dev/null +++ b/lsp/gopls.lua @@ -0,0 +1,4 @@ +return { + cmd = { "gopls" }, + filetypes = { "go", "gomod", "gowork", "gotmpl" } +} diff --git a/lsp/lemminx.lua b/lsp/lemminx.lua new file mode 100644 index 0000000..1708328 --- /dev/null +++ b/lsp/lemminx.lua @@ -0,0 +1,4 @@ +return { + cmd = { "lemminx" }, + filetypes = { "xml", "xsd", "xsl", "xslt", "svg" } +} diff --git a/lsp/lua_ls.lua b/lsp/lua_ls.lua new file mode 100644 index 0000000..d5ab2e5 --- /dev/null +++ b/lsp/lua_ls.lua @@ -0,0 +1,4 @@ +return { + cmd = { "lua-language-server" }, + filetypes = { "lua" } +} diff --git a/lsp/pyright.lua b/lsp/pyright.lua new file mode 100644 index 0000000..0b2fc88 --- /dev/null +++ b/lsp/pyright.lua @@ -0,0 +1,14 @@ +return { + cmd = { "pyright-langserver", "--stdio" }, + filetypes = { "python" }, + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = "openFilesOnly", + useLibraryCodeForTypes = true + } + } + }, + single_file_support = true +} diff --git a/lsp/ruff.lua b/lsp/ruff.lua new file mode 100644 index 0000000..261a847 --- /dev/null +++ b/lsp/ruff.lua @@ -0,0 +1,4 @@ +return { + cmd = { "ruff", "server" }, + filetypes = { "python" } +} diff --git a/lsp/tailwindcss.lua b/lsp/tailwindcss.lua new file mode 100644 index 0000000..1d4beee --- /dev/null +++ b/lsp/tailwindcss.lua @@ -0,0 +1,26 @@ +return { + cmd = { "tailwindcss-language-server", "--stdio" }, + filetypes = { "aspnetcorerazor", "astro", "astro-markdown", "blade", "clojure", "django-html", "htmldjango", "edge", "eelixir", "elixir", "ejs", "erb", "eruby", "gohtml", "gohtmltmpl", "haml", "handlebars", "hbs", "html", "htmlangular", "html-eex", "heex", "jade", "leaf", "liquid", "markdown", "mdx", "mustache", "njk", "nunjucks", "php", "razor", "slim", "twig", "css", "less", "postcss", "sass", "scss", "stylus", "sugarss", "javascript", "javascriptreact", "reason", "rescript", "typescript", "typescriptreact", "vue", "svelte", "templ" }, + settings = { + tailwindCSS = { + classAttributes = { "class", "className", "classList", "class:list", "ngClass", "pathClassName" }, + experimental = { + classRegex = { + { + "(?:clsx|cva|cx)\\(([^)(]*(?:\\([^)(]*(?:\\([^)(]*(?:\\([^)(]*\\)[^)(]*)*\\)[^)(]*)*\\)[^)(]*)*)\\)", + "'([^']*)'", + }, + { + "(?:clsx|cva|cx)\\(([^)(]*(?:\\([^)(]*(?:\\([^)(]*(?:\\([^)(]*\\)[^)(]*)*\\)[^)(]*)*\\)[^)(]*)*)\\)", + '"([^"]*)"', + }, + { + "(?:clsx|cva|cx)\\(([^)(]*(?:\\([^)(]*(?:\\([^)(]*(?:\\([^)(]*\\)[^)(]*)*\\)[^)(]*)*\\)[^)(]*)*)\\)", + "`([^`]*)`", + }, + }, + }, + }, + }, + +} diff --git a/lsp/vtsls.lua b/lsp/vtsls.lua new file mode 100644 index 0000000..0f13ddb --- /dev/null +++ b/lsp/vtsls.lua @@ -0,0 +1,4 @@ +return { + cmd = { "vtsls", "--stdio" }, + filetypes = { "javascript", "javascriptreact", "javascript.jsx", "typescript", "typescriptreact", "typescript.tsx" } +} diff --git a/lua/config/init.lua b/lua/config/init.lua new file mode 100644 index 0000000..966a7d3 --- /dev/null +++ b/lua/config/init.lua @@ -0,0 +1,2 @@ +require("config.settings") +require("config.lazy") \ No newline at end of file diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua new file mode 100644 index 0000000..a360577 --- /dev/null +++ b/lua/config/lazy.lua @@ -0,0 +1,24 @@ +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ + spec = { + { import = "plugins" }, + } +}) + + + diff --git a/lua/config/settings.lua b/lua/config/settings.lua new file mode 100644 index 0000000..874427f --- /dev/null +++ b/lua/config/settings.lua @@ -0,0 +1,61 @@ +local opt = vim.opt + +local wo = vim.wo +local cmd = vim.cmd +local g = vim.g + +g.mapleader = "\\" +g.maplocalleader = " " + +opt.cindent = true +opt.colorcolumn = "80" +opt.clipboard:append({ "unnamed", "unnamedplus" }) +opt.expandtab = true +opt.exrc = true +opt.foldmethod = "syntax" +opt.foldcolumn = "1" +opt.foldlevelstart = 20 +opt.ignorecase = true +opt.incsearch = true +opt.inccommand = "split" +opt.mouse = "a" +opt.completeopt = "menuone,noselect" +wo.wrap = false +opt.number = true +opt.path = { "." } +opt.signcolumn = "yes" +opt.shiftwidth = 2 +opt.smartcase = true +opt.smarttab = true +opt.spell = false +opt.spelllang = "en_us" +opt.scrolloff = 8 +opt.relativenumber = true +opt.tabstop = 2 +opt.wildignore = { + "node_modules/**", + ".git/**", + ".settings/**", + ".mvn/**", + "*.pyc", +} +opt.wildcharm = vim.fn.char2nr("") +opt.list = true +opt.listchars = "eol:↩,tab: " + +opt.title = true +opt.showmode = false + +vim.o.updatetime = 250 +vim.o.ch = 0 + +opt.syntax = "enable" + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undodir = vim.fn.expand("~/.vim/undodir") +vim.opt.undofile = true + +if vim.fn.has("termguicolors") == 1 then + opt.termguicolors = true +end diff --git a/lua/plugins/blink.lua b/lua/plugins/blink.lua new file mode 100644 index 0000000..5df40ba --- /dev/null +++ b/lua/plugins/blink.lua @@ -0,0 +1,21 @@ +return { + { + 'saghen/blink.cmp', + dependencies = 'rafamadriz/friendly-snippets', + version = '*', + ---@module 'blink.cmp' + ---@type blink.cmp.Config + opts = { + keymap = { preset = 'default' }, + appearance = { + use_nvim_cmp_as_default = true, + nerd_font_variant = 'mono' + }, + signature = { enabled = true }, + completion = { + documentation = { auto_show = true, auto_show_delay_ms = 500 }, + }, + }, + opts_extend = { "sources.default" }, + } } + diff --git a/lua/plugins/commander.lua b/lua/plugins/commander.lua new file mode 100644 index 0000000..3e5eaab --- /dev/null +++ b/lua/plugins/commander.lua @@ -0,0 +1,154 @@ +return { + { + "FeiyouG/commander.nvim", + dependencies = { "nvim-telescope/telescope.nvim" }, + init = function() + require("commander").setup({ + integration = { + telescope = { + enable = true, + theme = require("telescope.themes").commander, + }, + lazy = { + enable = true, + set_plugin_name_as_cat = true, + }, + }, + }) + require("commander").add({ + { + desc = "Find git files", + cmd = ":FzfLua git_files", + }, + { + cmd = ":FzfLua files", + desc = "Find files", + }, + { + cmd = ":FzfLua buffers", + desc = "Buffer list", + }, + { + cmd = ":FzfLua quickfix", + desc = "Quickfix", + }, + { + cmd = ":FzfLua quickfix_stack", + desc = "Quickfix History", + }, + { + cmd = ":FzfLua command_history", + desc = "Command History", + }, + { + cmd = ":FzfLua git_commits", + desc = "Git commits", + }, + { + cmd = ":FzfLua git_bcommits", + desc = "Git buffer commits", + }, + { + cmd = ":FzfLua git_branches", + desc = "Git branches", + }, + { + cmd = ":GV", + desc = "Git log", + }, + { + cmd = ":Git blame", + desc = "Git blame", + }, + { + cmd = ":DiffviewOpen", + desc = "Diff view", + }, + { + cmd = ":UndotreeToggle", + desc = "Undotree", + }, + { + cmd = ":EslintFixAll", + desc = "ESLint: autofix all problems", + }, + { + cmd = ":'<,'>sort", + desc = "Sort", + }, + { + cmd = ":Fidget history", + desc = "Error/notification history", + }, + { + cmd = ":lua Snacks.terminal.toggle()", + desc = "Terminal", + keys = { "n", "t" }, + set = false, + }, + { + cmd = ":GitConflicts", + desc = "Git conflicts to quickfix", + }, + { + cmd = ":LastCommitToQuickfix", + desc = "Last Commit To quickfix", + }, + { + cmd = ":ForkToQuickfix", + desc = "Branch commits to quickfix", + }, + { + cmd = ":Trouble diagnostics toggle focus=false filter.buf=0", + desc = "Diagnostic window (current buffer)", + }, + { + cmd = ":Trouble symbols toggle pinned=true results.win.relative=win results.win.position=right", + desc = "Symbols", + }, + { + cmd = ":PackageInfoShow", + desc = "Show package.json versions", + }, + { + cmd = ":PackageInfoHide", + desc = "Hide package.json versions", + }, + { + cmd = ":PackageInfoUpdate", + desc = "Update package.json dependency", + }, + { + cmd = ":CoAuthor", + desc = "Add Git CoAuthor", + }, + { + cmd = ":TailwindConcealToggle", + desc = "Toggle conceal tailwind classes", + }, + }) + + vim.api.nvim_create_user_command("Commander", function(args) + require("commander").show() + end, { + desc = "Show commands", + nargs = "*", + }) + + vim.api.nvim_create_user_command("LastCommitToQuickfix", function(args) + require("utils.telescope").last_commit_to_quickfix() + end, { + desc = "Last Commit To quickfix", + nargs = "?", + }) + + vim.api.nvim_create_user_command("ForkToQuickfix", function(args) + require("utils.telescope").fork_to_quickfix(args.fargs[1]) + end, { + desc = "Branch changes to quickfix", + nargs = "?", + }) + end, + }, +} + diff --git a/lua/plugins/flash.nvim.lua b/lua/plugins/flash.nvim.lua new file mode 100644 index 0000000..2fd8b61 --- /dev/null +++ b/lua/plugins/flash.nvim.lua @@ -0,0 +1,5 @@ +return {{ + "folke/flash.nvim", + event = "VeryLazy", + opts = {}, +}} diff --git a/lua/plugins/fzf-lua.lua b/lua/plugins/fzf-lua.lua new file mode 100644 index 0000000..f5333a0 --- /dev/null +++ b/lua/plugins/fzf-lua.lua @@ -0,0 +1,14 @@ +return { + { + "ibhagwan/fzf-lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("fzf-lua").setup({ + keymap = { + fzf = { + ["ctrl-q"] = "select-all+accept", + }, + }, + }) + end + } } diff --git a/lua/plugins/glance.lua b/lua/plugins/glance.lua new file mode 100644 index 0000000..c013189 --- /dev/null +++ b/lua/plugins/glance.lua @@ -0,0 +1,50 @@ +return { + "dnlhc/glance.nvim", + config = function() + local glance = require("glance") + local actions = glance.actions + glance.setup({ + border = { + enable = true, + }, + folds = { + fold_closed = "", + fold_open = "", + folded = false, -- Automatically fold list on startup + }, + mappings = { + list = { + ["j"] = actions.next, -- Bring the cursor to the next item in the list + ["k"] = actions.previous, -- Bring the cursor to the previous item in the list + [""] = actions.next, + [""] = actions.previous, + ["J"] = actions.next_location, + ["K"] = actions.previous_location, + [""] = actions.preview_scroll_win(5), + [""] = actions.preview_scroll_win(-5), + ["v"] = actions.jump_vsplit, + ["s"] = actions.jump_split, + ["t"] = actions.jump_tab, + [""] = actions.jump, + [""] = actions.enter_win("preview"), -- Focus preview window + ["q"] = actions.close, + ["Q"] = actions.close, + [""] = actions.close, + [""] = actions.quickfix, + -- [''] = false -- disable a mapping + }, + preview = { + ["Q"] = actions.close, + ["q"] = actions.close, + ["J"] = actions.next_location, + ["K"] = actions.previous_location, + [""] = actions.enter_win("list"), -- Focus list window + }, + }, + winbar = { + enable = false, + }, + use_trouble_qf = true, + }) + end +} diff --git a/lua/plugins/hurl.nvim.lua b/lua/plugins/hurl.nvim.lua new file mode 100644 index 0000000..d363bc1 --- /dev/null +++ b/lua/plugins/hurl.nvim.lua @@ -0,0 +1,86 @@ +local function load_env(file) + local env_vars = {} + local env_file = io.open(file, "r") + if not env_file then return env_vars end + + for line in env_file:lines() do + local key, value = line:match("([^=]+)=([^=]+)") + if key and value then + env_vars[key] = value + vim.fn.setenv(key, value) -- Optionally set it in Neovim's environment + end + end + + env_file:close() + return env_vars +end + +return { + "jellydn/hurl.nvim", + dependencies = { + "MunifTanjim/nui.nvim", + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + -- Optional, for markdown rendering with render-markdown.nvim + { + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { "markdown" }, + }, + ft = { "markdown" }, + }, + }, + ft = "hurl", + opts = { + -- Show debugging info + debug = false, + -- Show notification on run + show_notification = false, + -- Show response in popup or split + mode = "split", + -- Default formatter + formatters = { + json = { 'jq' }, -- Make sure you have install jq in your system, e.g: brew install jq + html = { + 'prettier', -- Make sure you have install prettier in your system, e.g: npm install -g prettier + '--parser', + 'html', + }, + xml = { + 'tidy', -- Make sure you have installed tidy in your system, e.g: brew install tidy-html5 + '-xml', + '-i', + '-q', + }, + }, + mappings = { + close = 'q', -- Close the response popup or split view + next_panel = '', -- Move to the next response popup window + prev_panel = '', -- Move to the previous response popup window + }, + fixture_vars = { + { + name = 'CARBONCENTRAL_FIREBASE_TOKEN', + callback = function() + local vars = load_env("vars.env") + local firebaseUrl = vars["FIREBASE_URL"] + local firebaseKey = vars["FIREBASE_KEY"] + local email = vars["FIREBASE_EMAIL"] + local password = vars["FIREBASE_PASSWORD"] + + local h = io.popen( + "curl --header \"Content-Type: application/json\" --request POST --data '{\"returnSecureToken\":true,\"email\":\"" .. + email .. + "\",\"password\":\"" .. + password .. + "\",\"clientType\":\"CLIENT_TYPE_WEB\"}' " .. firebaseUrl .. "?key=" .. + firebaseKey) + local rawdata = h:read("all") + h:close() + local t = vim.json.decode(rawdata) + return t["idToken"] + end + }, + } + }, +} diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua new file mode 100644 index 0000000..50fc088 --- /dev/null +++ b/lua/plugins/lsp.lua @@ -0,0 +1,86 @@ +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +local format_on_save = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ + group = augroup, + buffer = bufnr, + }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ + bufnr = bufnr, + async = false, + }) + end, + }) + end +end + +local configs = {} +for _, v in ipairs(vim.api.nvim_get_runtime_file('lsp/*', true)) do + local name = vim.fn.fnamemodify(v, ':t:r') + configs[name] = true +end +vim.lsp.enable(vim.tbl_keys(configs)) + +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if not client then return end + + if vim.bo.filetype == "lua" or client.name == "jdtls" then + -- Format the current buffer on save + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = args.buf, + callback = function() + vim.lsp.buf.format({ bufnr = args.buf, id = client.id }) + end, + }) + end + end, +}) + +vim.diagnostic.config({ + virtual_lines = true +}) + +return { + { + "williamboman/mason.nvim", + opts = { + tools_to_install = { + "lua-language-server", "vtsls", "ruff", "mypy", "black", "pyright", "tailwindcss-language-server", + "eslint-lsp", "lemminx", "gopls" + } + }, + config = function(_, opts) + require("mason").setup() + local mason_registry = require("mason-registry") + mason_registry.refresh() + for _, tool in pairs(opts.tools_to_install) do + local package = mason_registry.get_package(tool) + if not package:is_installed() then + package:install() + end + end + end + }, + { + "nvimtools/none-ls.nvim", + config = function(_, opts) + local null_ls = require("null-ls") + null_ls.setup({ + on_attach = function(client, bufnr) + format_on_save(client, bufnr) + end, + sources = { + null_ls.builtins.formatting.prettier, + }, + }) + end + } + + +} diff --git a/lua/plugins/lspsaga.nvim.lua b/lua/plugins/lspsaga.nvim.lua new file mode 100644 index 0000000..8791c9e --- /dev/null +++ b/lua/plugins/lspsaga.nvim.lua @@ -0,0 +1,44 @@ +return +{ + 'nvimdev/lspsaga.nvim', + config = function() + require('lspsaga').setup({ + symbol_in_winbar = { + enable = true, + hide_keyboard = true, + }, + lightbulb = { + enable = true, + enable_in_insert = true, + cache_code_action = true, + sign = true, + update_time = 150, + sign_priority = 20, + virtual_text = false, + }, + diagnostic = { + extend_relatedInformation = true, + }, + finder = { + keys = { + vsplit = "s", + split = "v", + toggle_or_open = "", + shuttle = "", + }, + }, + outline = { + keys = { + toggle_or_jump = "", + }, + }, + implement = { + enable = false, + }, + }) + end, + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-tree/nvim-web-devicons', + } +} diff --git a/lua/plugins/mini.files.lua b/lua/plugins/mini.files.lua new file mode 100644 index 0000000..f4f4124 --- /dev/null +++ b/lua/plugins/mini.files.lua @@ -0,0 +1,3 @@ +return { + { 'echasnovski/mini.files', version = '*', opts = {} } +} diff --git a/lua/plugins/mini.statusline.lua b/lua/plugins/mini.statusline.lua new file mode 100644 index 0000000..a6417da --- /dev/null +++ b/lua/plugins/mini.statusline.lua @@ -0,0 +1,3 @@ +return { + { 'echasnovski/mini.statusline', version = '*',opts = {} }, +} diff --git a/lua/plugins/namu.nvim.lua b/lua/plugins/namu.nvim.lua new file mode 100644 index 0000000..6c57596 --- /dev/null +++ b/lua/plugins/namu.nvim.lua @@ -0,0 +1,24 @@ +return { + { + "bassamsdata/namu.nvim", + config = function() + require("namu").setup({ + -- Enable the modules you want + namu_symbols = { + enable = true, + options = {}, -- here you can configure namu + }, + -- Optional: Enable other modules if needed + ui_select = { enable = false }, -- vim.ui.select() wrapper + colorscheme = { + enable = false, + options = { + -- NOTE: if you activate persist, then please remove any vim.cmd("colorscheme ...") in your config, no needed anymore + persist = true, -- very efficient mechanism to Remember selected colorscheme + write_shada = false, -- If you open multiple nvim instances, then probably you need to enable this + }, + }, + }) + end, + } +} diff --git a/lua/plugins/neo-tree.nvim.lua b/lua/plugins/neo-tree.nvim.lua new file mode 100644 index 0000000..d57f988 --- /dev/null +++ b/lua/plugins/neo-tree.nvim.lua @@ -0,0 +1,18 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + opts = { + close_if_last_window = true, + filesystem = { + follow_current_file = { + enabled = true, + leave_dirs_open = true, + }, + }, + }, +} diff --git a/lua/plugins/nvim-autopairs.lua b/lua/plugins/nvim-autopairs.lua new file mode 100644 index 0000000..60861d6 --- /dev/null +++ b/lua/plugins/nvim-autopairs.lua @@ -0,0 +1,7 @@ +return { + { + "windwp/nvim-autopairs", + event = "InsertEnter", + opts = {}, + } +} diff --git a/lua/plugins/snacks.nvim.lua b/lua/plugins/snacks.nvim.lua new file mode 100644 index 0000000..7961f6c --- /dev/null +++ b/lua/plugins/snacks.nvim.lua @@ -0,0 +1,14 @@ +return { { + "folke/snacks.nvim", + priority = 1000, + lazy = false, + + opts = { + notifier = { enabled = true }, + terminal = { enabled = true }, + indent = { enabled = true, only_scope = true, only_current = false }, + git = { enabled = true }, + bufdelete = { enabled = true }, + }, +} } + diff --git a/lua/plugins/tokyonight.lua b/lua/plugins/tokyonight.lua new file mode 100644 index 0000000..035fa6b --- /dev/null +++ b/lua/plugins/tokyonight.lua @@ -0,0 +1,9 @@ +return { + "folke/tokyonight.nvim", + lazy = false, + priority = 1000, + init = function() +require("tokyonight").setup({transparent = true, dim_inactive = true, lualine_bold = true}) +vim.cmd("colo tokyonight-night") + end +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..0a94e85 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,32 @@ +return { + 'nvim-treesitter/nvim-treesitter', + run = ':TSUpdate', + config = function() + local configs = require("nvim-treesitter.configs") + + configs.setup({ + ensure_installed = { + "c", + "lua", + "vim", + "vimdoc", + "query", + "elixir", + "heex", + "javascript", + "html", + "markdown", + "markdown_inline", + "html", + "jsdoc", + "hurl", + "typescript" + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + auto_install = true, + }) + end +} + diff --git a/lua/plugins/vim-fugitive.lua b/lua/plugins/vim-fugitive.lua new file mode 100644 index 0000000..12cc19c --- /dev/null +++ b/lua/plugins/vim-fugitive.lua @@ -0,0 +1 @@ +return {{"tpope/vim-fugitive"}} diff --git a/lua/plugins/which-key.nvim.lua b/lua/plugins/which-key.nvim.lua new file mode 100644 index 0000000..192dc31 --- /dev/null +++ b/lua/plugins/which-key.nvim.lua @@ -0,0 +1,301 @@ +return { + { + "folke/which-key.nvim", + init = function() + local wk = require("which-key") + wk.add({ + { "", ":m .+1==", desc = "Move line down" }, + { "", ":m .-2==", desc = "Move line up" }, + { + mode = "v", + { "", ":m '>+1gv=gv", desc = "Move line down" }, + { "", ":m '<-2gv=gv", desc = "Move line up" }, + }, + { + mode = "i", + { "", ":m .+1==gi", desc = "Move line down" }, + { "", ":m .-2==gi", desc = "Move line up" }, + }, + + { "", "Commander", desc = "Commander" }, + + { "", "FzfLua git_files", desc = "Find git files" }, + + { ",", group = "Search" }, + { ",p", "FzfLua files", desc = "Files files" }, + { ",b", "FzfLua buffers", desc = "Buffer List" }, + { ",q", "FzfLua quickfix", desc = "Quickfix" }, + { ",c", "FzfLua command_history", desc = "Quickfix" }, + { ",e", ":e **/*", desc = "Open with autocomplete" }, + { ",f", ":find **/*", desc = "Find with autocomplete" }, + + { "p", group = "Search" }, + { "pc", "FzfLua git_commits", desc = "Git commits" }, + { "pf", "FzfLua git_bcommits", desc = "Git file history" }, + { "pb", "FzfLua git_branches", desc = "Git branches" }, + { "ph", "FzfLua git_statuscr>", desc = "Git status" }, + { + "ps", + "FzfLua live_grep", + desc = "Project search" + }, + + -- { + -- "ds", + -- function() + -- require("utils.telescope").search_dotfiles() + -- end, + -- desc = "Search dot files 🔭", + -- }, + + { "K", "Lspsaga hover_doc", desc = "Show documentation" }, + { "", "Lspsaga hover_doc ++keep", desc = "Show documentation (keep)" }, + { "", "Lspsaga rename", desc = "Rename variable" }, + { "g", group = "Go to" }, + { "gd", ":Lspsaga goto_definition", desc = "Go to definition" }, + { + "gD", + function() + vim.lsp.buf.declaration() + end, + desc = "Go to declaration", + }, + { "gt", ":Lspsaga goto_type_definition", desc = "Go to type definition" }, + { "gh", ":Lspsaga finder", desc = "LSP Finder" }, + { "gH", ":Lspsaga finder ++normal", desc = "LSP Finder (keep)" }, + { "gj", ":Lspsaga diagnostic_jump_next", desc = "Next diagnostic message" }, + { "gk", ":Lspsaga diagnostic_jump_prev", desc = "Previous diagnostic message" }, + + { "a", group = "Local File Actions" }, + { "ac", "Lspsaga code_action", desc = "Code action" }, + { + "ag", + function() + vim.diagnostic.open_float(0, { scope = "line", focusable = false }) + end, + desc = "Show line diagnostics", + }, + { + "ad", + "Glance definitions", + desc = "Definitions", + }, + { + "ar", + "Glance references", + desc = "References", + }, + { + "ai", + "Glance implementations", + desc = "References", + }, + { + "at", + "Glance type_definitions", + desc = "Type definitions", + }, + { + "aI", + "Lspsaga incoming_calls", + desc = "Incoming calls", + }, + { + "aO", + "Lspsaga outgoing_calls", + desc = "Outgoing calls", + }, + + { + "O", + "Lspsaga outline", + desc = "Toggle Outline", + icon = "󰷐", + }, + + { + "g", + group = "Git", + }, + { + "gd", + "DiffviewOpen", + desc = "Diff view", + }, + + { + "»", + "]", + noremap = false, + }, + { + "«", + "[", + noremap = false, + }, + { "h", group = "git signs" }, + { + "hs", + function() + require("gitsigns").stage_hunk() + end, + desc = "Stage hunk", + }, + { + "hu", + function() + require("gitsigns").undo_stage_hunk() + end, + desc = "Undo stage hunk", + }, + { + "hv", + function() + require("gitsigns").preview_hunk() + end, + desc = "Preview hunk", + }, + { + "hb", + function() + require("gitsigns").blame_line() + end, + desc = "Blame line", + }, + { + "hR", + function() + require("gitsigns").reset_buffer() + end, + desc = "Reset buffer", + }, + { + "hr", + function() + require("gitsigns").reset_hunk() + end, + desc = "Reset hunk", + }, + { + "hS", + function() + require("gitsigns").stage_buffer() + end, + desc = "Stage buffer", + }, + { + "hU", + function() + require("gitsigns").reset_buffer_index() + end, + desc = "Reset buffer index", + }, + { + mode = "v", + { + "hs", + function() + require("gitsigns").stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, + desc = "Stage hunk", + }, + { + "hr", + function() + require("gitsigns").reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) + end, + desc = "Reset hunk", + }, + }, + + { + "]c", + function() + if vim.wo.diff then + vim.cmd.normal({ "]c", bang = true }) + else + vim.schedule(function() + require("gitsigns").nav_hunk("next") + end) + end + end, + desc = "Next hunk", + }, + { + "[c", + function() + if vim.wo.diff then + vim.cmd.normal({ "[c", bang = true }) + else + vim.schedule(function() + require("gitsigns").nav_hunk("prev") + end) + end + end, + desc = "Previous hunk", + }, + + { "u", "UndotreeToggle", desc = "Undotree", icon = "" }, + + { "c", group = "quickfix" }, + { "co", "copen", desc = "Open" }, + { "cf", "cfirst", desc = "First result" }, + { "cl", "clast", desc = "Last result" }, + { "cn", "cnext", desc = "Next result" }, + { "cp", "cprevious", desc = "Previous result" }, + { "cc", "cclose", desc = "Close" }, + + { "c", group = "Location List" }, + { "co", "lopen", desc = "Open" }, + { "cf", "lfirst", desc = "First result" }, + { "cl", "llast", desc = "Last result" }, + { "cn", "lnext", desc = "Next result" }, + { "cp", "lprevious", desc = "Previous result" }, + { "cc", "lclose", desc = "Close" }, + + { "", "Neotree toggle", desc = "Toggle neo-tree" }, + + { "t", "lua Snacks.terminal.toggle()", desc = "Toggle Terminal" }, + { mode = { "t" }, { "t", "lua Snacks.terminal.toggle()", desc = "Toggle Terminal" } }, + + { + mode = { "n", "x", "o" }, + { + "s", + function() + require("flash").jump() + end, + desc = "Flash ⚡", + }, + { + "S", + function() + require("flash").treesitter() + end, + desc = "Flash Treesitter ⚡", + }, + }, + { + mode = { "o", "x" }, + { + "R", + function() + require("flash").treesitter_search() + end, + desc = "Flash Treesitter search ⚡", + }, + }, + { + mode = "c", + { + "", + function() + require("flash").toggle() + end, + desc = "Toggle Flash Search ⚡", + }, + }, + }) + end, + } +}