From 4a074cc247b1256649074766578899b4ced200de Mon Sep 17 00:00:00 2001 From: amolinae06 Date: Wed, 19 Mar 2025 22:21:14 -0600 Subject: [PATCH] added plugins --- init.lua | 56 ++++++++++++++++++++++++++++++++++++-- lua/config/lazy.lua | 2 +- lua/config/mappings.lua | 49 +++++++++++++++++++++++++++++++++ lua/config/plugins/cmp.lua | 2 +- lua/config/plugins/lsp.lua | 4 --- lua/config/settings.lua | 10 +++---- lua/plugins/autosave.lua | 20 ++++++++++++++ lua/plugins/cmp.lua | 30 ++++++++++++-------- lua/plugins/lspconfig.lua | 9 +++++- lua/plugins/neotree.lua | 4 +-- lua/plugins/nonels.lua | 3 +- lua/plugins/telescope.lua | 6 +--- lua/plugins/ui.lua | 52 +++++++++++++++++++++++++++++------ 13 files changed, 204 insertions(+), 43 deletions(-) create mode 100644 lua/config/mappings.lua create mode 100644 lua/plugins/autosave.lua diff --git a/init.lua b/init.lua index c49fa50..7d37373 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,56 @@ -require("config.lazy") require("config.settings") +require("config.lazy") +require("config.mappings") -vim.cmd.colorscheme("neopywal") +vim.cmd.colorscheme("pywal16") +local tn_colors = require("tokyonight.colors").setup({ style = "storm" }) + +local syntax_overrides = { + { "Comment", tn_colors.comment, true }, + { "Constant", tn_colors.orange }, + { "String", tn_colors.green }, + { "Character", tn_colors.green }, + { "Number", tn_colors.orange }, + { "Boolean", tn_colors.orange }, + { "Float", tn_colors.orange }, + { "Identifier", tn_colors.cyan }, + { "Function", tn_colors.blue, true }, + { "Statement", tn_colors.magenta }, + { "Conditional", tn_colors.magenta }, + { "Repeat", tn_colors.magenta }, + { "Label", tn_colors.blue }, + { "Operator", tn_colors.magenta }, + { "Keyword", tn_colors.magenta }, + { "Exception", tn_colors.magenta }, + { "PreProc", tn_colors.blue }, + { "Include", tn_colors.blue }, + { "Define", tn_colors.blue }, + { "Macro", tn_colors.blue }, + { "Type", tn_colors.yellow }, + { "StorageClass", tn_colors.yellow }, + { "Structure", tn_colors.yellow }, + { "Typedef", tn_colors.yellow }, + { "Special", tn_colors.red }, + { "Delimiter", tn_colors.fg }, + { "SpecialComment", tn_colors.comment }, + { "Debug", tn_colors.red }, + + { "DiagnosticError", tn_colors.error, true }, + { "DiagnosticWarn", tn_colors.warning, true }, + { "DiagnosticInfo", tn_colors.blue }, + { "DiagnosticHint", tn_colors.hint }, + + { "DiagnosticUnderlineError", tn_colors.error, false, true }, + { "DiagnosticUnderlineWarn", tn_colors.warning, false, true }, + { "DiagnosticUnderlineInfo", tn_colors.blue, false, true }, + { "DiagnosticUnderlineHint", tn_colors.hint, false, true }, + + { "DiagnosticVirtualTextError", tn_colors.error, false, false, nil }, + { "DiagnosticVirtualTextWarn", tn_colors.warning, false, false, nil }, + { "DiagnosticVirtualTextInfo", tn_colors.blue, false, false, nil }, + { "DiagnosticVirtualTextHint", tn_colors.hint, false, false, nil } +} + +for _, group in ipairs(syntax_overrides) do + vim.api.nvim_set_hl(0, group[1], { fg = group[2], bold = group[3] or false, italic = group[4] or false, bg = group[5] or nil }) +end diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 62eb07e..1132bdd 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -31,5 +31,5 @@ require("lazy").setup({ -- colorscheme that will be used when installing plugins. install = { colorscheme = { "neopywal" } }, -- automatically check for plugin updates - checker = { enabled = true }, + checker = { enabled = false }, }) diff --git a/lua/config/mappings.lua b/lua/config/mappings.lua new file mode 100644 index 0000000..a2e2780 --- /dev/null +++ b/lua/config/mappings.lua @@ -0,0 +1,49 @@ +local map = vim.keymap.set + +-- Set mapleader +vim.g.mapleader = " " + +-- Disable arrow keys in normal, visual, and insert modes. +local keys = { "", "", "", "" } +for _, key in ipairs(keys) do + map({ "n", "i", "v" }, key, "", { noremap = true, silent = true }) +end + +-- Toggle spellcheck (When working with LaTeX/Typst) +local spelllangs = {"es_mx", "en_us"} +local current_index = 1 + +function ToggleSpell() + vim.o.spelllang = spelllangs[current_index] + vim.o.spell = not vim.o.spell + print("Spellcheck " .. (vim.o.spell and "enabled" or "disabled") .. ": " .. spelllangs[current_index]) +end + +map("n", "ts", ":lua ToggleSpell()", { noremap = true, silent = true }) + +-- Toggle spellcheck language. +function ToggleSpellLang() + current_index = (current_index % #spelllangs) + 1 + vim.o.spelllang = spelllangs[current_index] + print("Spelllang: " .. spelllangs[current_index]) +end + +map("n", "sp", ":lua ToggleSpellLang()", { noremap = true, silent = true }) + +-- Open terminal +map("n", "t", "8split | terminal", { noremap = true, silent = true }) + +-- Neotree +map("n", "", "Neotree toggle", { desc = "open neotree"}) + +-- Telescope +map("n", "", "Telescope find_files", { desc = "telescope find files" }) +map("n", "", "Telescope live_grep", { desc = "telescope live grep" }) + +-- Nonels +map("n", "gf", vim.lsp.buf.format, {}) + +-- LSP Stuff +map('n', 'K', vim.lsp.buf.hover, {}) +map('n', 'gd', vim.lsp.buf.definition, {}) +map({'n', 'v'}, 'ca', vim.lsp.buf.code_action, {}) diff --git a/lua/config/plugins/cmp.lua b/lua/config/plugins/cmp.lua index e63b957..b8f9866 100644 --- a/lua/config/plugins/cmp.lua +++ b/lua/config/plugins/cmp.lua @@ -22,7 +22,7 @@ { name = 'nvim_lsp' }, { name = 'luasnip' }, -- For luasnip users. { name = 'nvim_lua' }, - { name = 'buffer' }, + -- { name = 'buffer' }, { name = 'path' }, { name = 'nvim_lsp_signature_help' }, -- { name = 'cmdline' }, diff --git a/lua/config/plugins/lsp.lua b/lua/config/plugins/lsp.lua index 61c98ed..e7b4600 100644 --- a/lua/config/plugins/lsp.lua +++ b/lua/config/plugins/lsp.lua @@ -1,6 +1,2 @@ local lspconfig = require("lspconfig") lspconfig.lua_ls.setup({}) - -vim.keymap.set('n', 'K', vim.lsp.buf.hover, {}) -vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) -vim.keymap.set({'n', 'v'}, 'ca', vim.lsp.buf.code_action, {}) diff --git a/lua/config/settings.lua b/lua/config/settings.lua index e9a44d1..282008a 100644 --- a/lua/config/settings.lua +++ b/lua/config/settings.lua @@ -30,17 +30,17 @@ o.inccommand = "split" o.splitright = true o.splitbelow = true o.termguicolors = true - -opt.shortmess:append "sI" -opt.whichwrap:append "<>[]hl" -opt.fillchars = { eob = " " } - o.updatetime = 250 o.ignorecase = true o.incsearch = true o.smartcase = true o.mouse = "a" +opt.shortmess:append "sI" +opt.whichwrap:append "<>[]hl" +opt.fillchars = { eob = " " } +opt.termguicolors = true + g.loaded_node_provider = 0 g.loaded_python3_provider = 0 g.loaded_perl_provider = 0 diff --git a/lua/plugins/autosave.lua b/lua/plugins/autosave.lua new file mode 100644 index 0000000..655002f --- /dev/null +++ b/lua/plugins/autosave.lua @@ -0,0 +1,20 @@ +return { + { + "okuuva/auto-save.nvim", + version = '^1.0.0', + cmd = "ASToggle", + event = { "InsertLeave", "TextChanged" }, + opts = { + enabled = true, + trigger_events = { + immediate_save = { + { "BufLeave", pattern = { "*.typ", "*.tex" } } + }, + defer_save = { + { "BufLeave", pattern = { "*.typ", "*.tex"} } + }, + cancel_deferred_save = { "InsertEnter" }, + }, + } + } +} diff --git a/lua/plugins/cmp.lua b/lua/plugins/cmp.lua index e2cfab5..b265d3b 100644 --- a/lua/plugins/cmp.lua +++ b/lua/plugins/cmp.lua @@ -13,6 +13,7 @@ return { opts = { fast_wrap = {}, disable_filetype = { "TelescopePrompt", "vim" }, + map_cr = true, }, config = function(opts) require("nvim-autopairs").setup(opts) @@ -20,6 +21,12 @@ return { local cmp = require('cmp') require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) end + }, + { + "lukas-reineke/indent-blankline.nvim", + event = "User FilePost", + main = "ibl", + opts = {} } }, opts = function() @@ -29,20 +36,21 @@ return { { "hrsh7th/cmp-nvim-lsp", dependencies = {}, - -- [[ config = function () local capabilities = require('cmp_nvim_lsp').default_capabilities() - require('lspconfig').clangd.setup { - capabilities = capabilities, + + local lsps = { + "clangd", "arduino_language_server", + "lua_ls", "pylsp", + "texlab", "tinymist", + "cssls", "html", } - require('lspconfig').pylsp.setup { - capabilities = capabilities - } - require('lspconfig').ltex.setup { - capabilities = capabilities - } - end, - --]] + + -- Load completion engines + for _, lsp in pairs(lsps) do + require('lspconfig')[lsp].setup { capabilities = capabilities } + end + end, }, { "L3MON4D3/LuaSnip", diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 2b26c4b..a80ab28 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -18,7 +18,14 @@ return { dependencies = {}, config = function() require("mason-lspconfig").setup { - ensure_installed = { "lua_ls" }, + ensure_installed = { + "lua_ls", + "tinymist", + "arduino_language_server", + "pylsp", + "texlab", + "clangd" + }, } end, } diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua index 2723273..9640cc5 100644 --- a/lua/plugins/neotree.lua +++ b/lua/plugins/neotree.lua @@ -7,8 +7,6 @@ return { "MunifTanjim/nui.nvim", -- "3rd/image.nvim", -- Optional see `# Preview Mode` for more information }, - opts = { - vim.keymap.set('n', '', 'Neotree toggle') - } + opts = {} } } diff --git a/lua/plugins/nonels.lua b/lua/plugins/nonels.lua index 707386d..e480c5b 100644 --- a/lua/plugins/nonels.lua +++ b/lua/plugins/nonels.lua @@ -6,10 +6,9 @@ return { null_ls.setup({ sources = { null_ls.builtins.formatting.stylua, - -- null_ls.builtins.completion.spell, + null_ls.builtins.completion.spell, }, }) - vim.keymap.set("n", "gf", vim.lsp.buf.format, {}) end, }, } diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 4a8f009..058aab6 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -2,11 +2,7 @@ return { { "nvim-telescope/telescope.nvim", dependencies = { 'nvim-lua/plenary.nvim' }, - config = function() - local builtin = require('telescope.builtin') - vim.keymap.set('n', '', builtin.find_files, { desc = 'Telescope find files' }) - vim.keymap.set('n', '', builtin.live_grep, { desc = 'Telescope live grep' }) - end, + opts = {} }, { "nvim-telescope/telescope-ui-select.nvim", diff --git a/lua/plugins/ui.lua b/lua/plugins/ui.lua index 7b334f8..f683f29 100644 --- a/lua/plugins/ui.lua +++ b/lua/plugins/ui.lua @@ -1,13 +1,29 @@ return { { - "RedsXDD/neopywal.nvim", - name = "neopywal", + 'uZer/pywal16.nvim', + opts = {}, + }, + { + "folke/tokyonight.nvim", + priority = 1000, opts = { - transparent_background = true, - terminal_colors = true, - show_end_of_buffer = false, + transparent = false, + styles = { + sidebars = "transparent", + floats = "transparent", + }, }, - }, + }, + { + "norcalli/nvim-colorizer.lua", + opts = { + 'css'; + 'javascript'; + html = { + mode = 'foreground'; + } + } + }, { -- Lua status-bar "nvim-lualine/lualine.nvim", @@ -15,12 +31,32 @@ return { opts = { options = { icons_enabled = true, - theme = 'auto', + theme = 'pywal16-nvim', component_separators = { left = "|", right = "|"}, - section_separators = { left = "", right = ""}, + section_separators = { left = "", right = ""}, } } }, + { + 'akinsho/bufferline.nvim', + version = "*", + dependencies = {'nvim-tree/nvim-web-devicons'}, + opts = { + options = { + mode = "buffers", + diagnostics = "nvim_lsp", + offsets = { + { + filetype = "neo-tree", + text = "File Explorer", + text_align = "center", + separator = true + } + }, + themable = false, + }, + } + }, { "nvim-treesitter/nvim-treesitter", event = { "BufReadPost", "BufNewFile" },