From 56758415b40197ff1e7dab653ab24af58727aa4e Mon Sep 17 00:00:00 2001 From: Elvis Claros Castro Date: Sat, 17 Aug 2024 18:37:18 -0300 Subject: Feat: update all --- lua/config/autocmds.lua | 11 +++++ lua/config/diagnostic.lua | 29 ++++++++++-- lua/config/keymaps.lua | 108 +++++++++++++++++++++++++++++++++++++------ lua/config/options.lua | 2 +- lua/pi/lsp/attach.lua | 2 +- lua/pi/lsp/init.lua | 2 +- lua/pi/lsp/null-ls.lua | 13 ++++-- lua/plugins/completition.lua | 18 +++++--- lua/plugins/firenvim.lua | 19 +++++++- lua/plugins/mini.lua | 7 +++ lua/plugins/oil.lua | 11 ++++- lua/plugins/smart-splits.lua | 8 ++-- lua/plugins/which-key.lua | 26 ++++++----- 13 files changed, 205 insertions(+), 51 deletions(-) create mode 100644 lua/plugins/mini.lua (limited to 'lua') diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index b62150e..9030e4e 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -49,3 +49,14 @@ if vim.fn.has("persistent_undo") then vim.o.undodir = target_path vim.o.undofile = true end +-- Función para alternar el ajuste de línea +function ToggleWrap() + local wrap = vim.wo.wrap + vim.wo.wrap = not wrap + if vim.wo.wrap then + print("Ajuste de línea: Habilitado") + else + print("Ajuste de línea: Deshabilitado") + end +end + diff --git a/lua/config/diagnostic.lua b/lua/config/diagnostic.lua index 67465ae..84d57b5 100644 --- a/lua/config/diagnostic.lua +++ b/lua/config/diagnostic.lua @@ -1,9 +1,28 @@ + vim.diagnostic.config { virtual_text = false, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = '', + [vim.diagnostic.severity.WARN] = '', + [vim.diagnostic.severity.INFO] = '', + [vim.diagnostic.severity.HINT] = '', + }, + linehl = { + [vim.diagnostic.severity.ERROR] = 'ErrorMsg', + }, + numhl = { + [vim.diagnostic.severity.WARN] = 'WarningMsg', + }, + }, } -local signs = { Error = "", Warn = "", Hint = "", Info = "" } -for type, icon in pairs(signs) do - local hl = "DiagnosticSign" .. type - vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) -end +-- vim.diagnostic.config { +-- virtual_text = false, +-- } +-- +-- local signs = { Error = "", Warn = "", Hint = "", Info = "" } +-- for type, icon in pairs(signs) do +-- local hl = "DiagnosticSign" .. type +-- vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) +-- end diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index 70f7511..73478de 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -69,21 +69,101 @@ map( { desc = "Save the current file and source it for .vim and .lua files" } ) -map("n", "vn", vim.diagnostic.goto_next, { desc = "Goes to next diagnostic error" }) -map("n", "vp", vim.diagnostic.goto_prev, { desc = "Goes to prev diagnostic error" }) +-- map("n", "vn", vim.diagnostic.goto_next, { desc = "Goes to next diagnostic error" }) +-- map("n", "vp", vim.diagnostic.goto_prev, { desc = "Goes to prev diagnostic error" }) +map( + "n", + "vn", + function() vim.diagnostic.jump({ count = 1, float = true }) end, + { desc = "Goes to next diagnostic error" } +) +map( + "n", + "vp", + function() vim.diagnostic.jump({ count = -1, float = true }) end, + { desc = "Goes to prev diagnostic error" } +) map("v", "q", require('pi.select_to_quickfix').handle) map('n', '99', ':set invspell', { noremap = true }) -- map("n", "ss", function() require('nvim-python-repl').send_statement_definition() end, { desc = "Send semantic unit to REPL"}) -vim.api.nvim_set_keymap('n', '', [[:lua require('nvim-python-repl').send_statement_definition()j]], {noremap = true, silent = true}) -vim.api.nvim_set_keymap('i', '', [[:lua require('nvim-python-repl').send_statement_definition()i]], {noremap = true, silent = true}) -map("n", "sl", function() require('nvim-python-repl').send_visual_to_repl() end, { desc = "Send visual selection to REPL"}) -map("v", "sl", function() require('nvim-python-repl').send_visual_to_repl() end, { desc = "Send visual selection to REPL"}) -map("n", "MReturn", function() require('nvim-python-repl').send_buffer_to_repl() end, { desc = "Send entire buffer to REPL"}) -map("n", "e", function() require('nvim-python-repl').toggle_execute() end, { desc = "Automatically execute command in REPL after sent"}) -map("n", "vi", function() require('nvim-python-repl').toggle_vertical() end, { desc = "Create REPL in vertical or horizontal split"}) -map("n", "rl",function() require('rust-tools').inlay_hints.enable() end, {desc = "Enable inlay hints auto update and set them for all the buffers"}) -map("n", "rdl",function() require('rust-tools').inlay_hints.disable() end, {desc = "Disable inlay hints auto update and unset them for all buffers"}) -map("n", "rrn", function () require('rust-tools').runnables.runnables() end, {desc = "run rust"}) -map("n", "-", "Oil", { desc = "Open parent directory" }) -map("n", "fg", function() require('telescope').extensions.live_grep_args.live_grep_args() end, {desc = "run grep"}) +vim.api.nvim_set_keymap( + 'n', + '', + [[:lua require('nvim-python-repl').send_statement_definition()j]], + {noremap = true, silent = true} +) +vim.api.nvim_set_keymap( + 'i', + '', + [[:lua require('nvim-python-repl').send_statement_definition()i]], + {noremap = true, silent = true} +) +map( + "n", + "sl", + function() require('nvim-python-repl').send_visual_to_repl() end, + { desc = "Send visual selection to REPL"} +) +map( + "v", + "sl", + function() require('nvim-python-repl').send_visual_to_repl() end, + { desc = "Send visual selection to REPL"} +) +map( + "n", + "MReturn", + function() require('nvim-python-repl').send_buffer_to_repl() end, + { desc = "Send entire buffer to REPL"} +) +map( + "n", + "e", + function() require('nvim-python-repl').toggle_execute() end, + { desc = "Automatically execute command in REPL after sent"} +) +map( + "n", + "vi", + function() require('nvim-python-repl').toggle_vertical() end, + { desc = "Create REPL in vertical or horizontal split"} +) +-- map( +-- "n", +-- "rl", +-- function() require('rust-tools').inlay_hints.enable() end, +-- {desc = "Enable inlay hints auto update and set them for all the buffers"} +-- ) +-- map( +-- "n", +-- "rdl", +-- function() require('rust-tools').inlay_hints.disable() end, +-- {desc = "Disable inlay hints auto update and unset them for all buffers"} +-- ) +-- map( +-- "n", +-- "rrn", +-- function () require('rust-tools').runnables.runnables() end, +-- {desc = "run rust"} +-- ) +map( + "n", + "-", + "Oil", + { desc = "Open parent directory" } +) +map( + "n", + "fg", + function() require('telescope').extensions.live_grep_args.live_grep_args() end, + {desc = "run grep"} +) + +-- Asignar la función a una tecla específica +vim.api.nvim_set_keymap( + 'n', + 'w', + ':lua ToggleWrap()', + { noremap = true, silent = true } +) diff --git a/lua/config/options.lua b/lua/config/options.lua index de3b12f..1400d03 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -37,7 +37,7 @@ opt.smartindent = true opt.errorbells = false -- Habilita el ajuste de línea. -opt.wrap = true +opt.wrap = false -- Habilita el corrector ortográfico. opt.spell = true diff --git a/lua/pi/lsp/attach.lua b/lua/pi/lsp/attach.lua index 7c28494..03002d6 100644 --- a/lua/pi/lsp/attach.lua +++ b/lua/pi/lsp/attach.lua @@ -24,6 +24,6 @@ return function(client, bufnr) vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" if client.server_capabilities.inlayHintProvider then - vim.lsp.inlay_hint.enable(bufnr) + vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled()) end end diff --git a/lua/pi/lsp/init.lua b/lua/pi/lsp/init.lua index 4454639..17d73a1 100644 --- a/lua/pi/lsp/init.lua +++ b/lua/pi/lsp/init.lua @@ -40,7 +40,7 @@ return { -- TODO: create an auto command that on write of the configuration, calls again the setup and restart the server if it's up. -- can get the client by name of the file - vim.api.nvim_create_user_command("AlphaLSP", function() + vim.api.nvim_create_user_command("PiLSP", function() vim.ui.select(servers, { prompt = "LSP Servers" }, function(server) if server == nil then return diff --git a/lua/pi/lsp/null-ls.lua b/lua/pi/lsp/null-ls.lua index b329ba6..b105018 100644 --- a/lua/pi/lsp/null-ls.lua +++ b/lua/pi/lsp/null-ls.lua @@ -5,13 +5,20 @@ local null_ls = require "null-ls" null_ls.setup { sources = { -- null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.formatting.jq, + require("none-ls.formatting.jq"), + require("none-ls.diagnostics.cpplint"), + require("none-ls.code_actions.eslint"), null_ls.builtins.code_actions.refactoring, null_ls.builtins.formatting.alejandra, - null_ls.builtins.diagnostics.luacheck, + require("none-ls-luacheck.diagnostics.luacheck"), null_ls.builtins.formatting.stylua, - null_ls.builtins.diagnostics.yamllint, + require("none-ls.diagnostics.yamllint"), + -- require("none-ls.diagnostics.ruff"), + -- require("none-ls.diagnostics.flake8"), + require("none-ls-shellcheck.diagnostics"), + require("none-ls-shellcheck.code_actions"), + -- null_ls.builtins.diagnostics.yamllint, -- php_actions.getter_setter, -- php_actions.file_creator, diff --git a/lua/plugins/completition.lua b/lua/plugins/completition.lua index 7366d7a..ab65317 100644 --- a/lua/plugins/completition.lua +++ b/lua/plugins/completition.lua @@ -27,18 +27,24 @@ return { { "uga-rosa/cmp-dictionary", config = function() + local dict_fl = { + ["*"] = { "/usr/share/dict/words" }, + ft = { + foo = { "./../../spell/dict_es.dict" }, + }, + } local dict = require("cmp_dictionary") dict.setup({ -- The following are default values. + + paths = dict_fl["*"], exact_length = 2, first_case_insensitive = false, - document = false, - document_command = "wn %s -over", - sqlite = false, - max_number_items = -1, - -- capacity = 5, - debug = false, + -- document = { + -- enable = true, + -- command = { "wn", "${label}", "-over" }, + -- }, }) -- dict.switcher({ diff --git a/lua/plugins/firenvim.lua b/lua/plugins/firenvim.lua index 0b69060..d39627b 100644 --- a/lua/plugins/firenvim.lua +++ b/lua/plugins/firenvim.lua @@ -1,10 +1,25 @@ return { 'glacambre/firenvim', + build = ":call firenvim#install(0)", -- Lazy load firenvim -- Explanation: https://github.com/folke/lazy.nvim/discussions/463#discussioncomment-4819297 lazy = not vim.g.started_by_firenvim, - build = function() - vim.fn["firenvim#install"](0) + config = function() + vim.g.firenvim_config = { + localSettings = { + ['.*'] = { + cmdline = 'none', + priority = 0, + selector = 'textarea', + takeover = 'never', + }, + }, + } + vim.api.nvim_create_autocmd({'BufEnter'}, { + pattern = "github.com_*.txt", + command = "set filetype=markdown" + }) end } + diff --git a/lua/plugins/mini.lua b/lua/plugins/mini.lua new file mode 100644 index 0000000..3fa0493 --- /dev/null +++ b/lua/plugins/mini.lua @@ -0,0 +1,7 @@ +return { + 'echasnovski/mini.nvim', + dependencies = { + 'echasnovski/mini.icons', + }, + version = false +} diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 58c0c13..947876e 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -3,8 +3,13 @@ return 'stevearc/oil.nvim', opts = {}, -- Optional dependencies - dependencies = { "nvim-tree/nvim-web-devicons" }, + dependencies = { + "nvim-tree/nvim-web-devicons", + "ElvisClaros/oil-image-preview.nvim", + }, config = function () + + local oip = require("oil-image-preview") require('oil').setup({ -- Oil will take over directory buffers (e.g. `vim .` or `:e src/`) -- Set to false if you still want to use netrw. @@ -25,7 +30,7 @@ return -- Window-local options to use for oil buffers win_options = { wrap = false, - signcolumn = "no", + signcolumn = "yes:3", cursorcolumn = false, foldcolumn = "0", spell = false, @@ -79,6 +84,8 @@ return ["gx"] = "actions.open_external", ["g."] = "actions.toggle_hidden", ["g\\"] = "actions.toggle_trash", + ["g"] = oip.openWithQuickLook, + ["gp"] = oip.weztermPreview, }, -- Configuration for the floating keymaps help window keymaps_help = { diff --git a/lua/plugins/smart-splits.lua b/lua/plugins/smart-splits.lua index 29cccb7..57faedb 100644 --- a/lua/plugins/smart-splits.lua +++ b/lua/plugins/smart-splits.lua @@ -3,28 +3,28 @@ return { config = true, keys = { { - "", + "", function() require("smart-splits").resize_left() end, desc = "Resize window left +10", }, { - "", + "", function() require("smart-splits").resize_down() end, desc = "Resize window down +10", }, { - "", + "", function() require("smart-splits").resize_up() end, desc = "Resize window up +10", }, { - "", + "", function() require("smart-splits").resize_right() end, diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 50cd483..b9a47db 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -1,14 +1,16 @@ return { - 'folke/which-key.nvim', - event = 'VeryLazy', - keys = { - { - -- See: https://github.com/folke/which-key.nvim/issues/476 - desc = 'Workaround for which-key not showing up on ', - '', - function() require('which-key').show(vim.g.maplocalleader) end, - }, + "folke/which-key.nvim", + event = "VeryLazy", + opts = { + preset = "modern" + }, + keys = { + { + "?", + function() + require("which-key").show({ global = false }) + end, + desc = "Buffer Local Keymaps (which-key)", }, - opts = {}, - init = function() vim.opt.timeoutlen = 300 end, - } + }, +} -- cgit v1.2.3