diff --git a/init.lua b/init.lua index 8d1f19a10d4..8804a07b5b5 100644 --- a/init.lua +++ b/init.lua @@ -164,6 +164,9 @@ vim.o.scrolloff = 10 -- See `:help 'confirm'` vim.o.confirm = true +-- Relative numbers in the quickfix window +vim.o.relativenumber = true + -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -556,6 +559,35 @@ require('lazy').setup({ -- For example, in C this would take you to the header. map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration') + -- Fuzzy find all the symbols in your current document. + -- Symbols are things like variables, functions, types, etc. + map('gO', require('telescope.builtin').lsp_document_symbols, 'Open Document Symbols') + + -- Fuzzy find all the symbols in your current workspace. + -- Similar to document symbols, except searches over your entire project. + map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, 'Open Workspace Symbols') + + -- 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 + -- the definition of its *type*, not where it was *defined*. + map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype Definition') + + -- Jump to the definition of the word under your cursor. + map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition') + + -- This function resolves a difference between neovim nightly (version 0.11) and stable (version 0.10) + ---@param client vim.lsp.Client + ---@param method vim.lsp.protocol.Method + ---@param bufnr? integer some lsp support methods only in specific files + ---@return boolean + local function client_supports_method(client, method, bufnr) + if vim.fn.has 'nvim-0.11' == 1 then + return client:supports_method(method, bufnr) + else + return client.supports_method(method, { bufnr = bufnr }) + end + end + -- The following two autocommands are used to highlight references of the -- word under your cursor when your cursor rests there for a little while. -- See `:help CursorHold` for information about when this is executed @@ -595,6 +627,72 @@ require('lazy').setup({ end, }) + -- Diagnostic Config + -- See :help vim.diagnostic.Opts + vim.diagnostic.config { + severity_sort = true, + float = { border = 'rounded', source = 'if_many' }, + underline = { severity = vim.diagnostic.severity.ERROR }, + signs = vim.g.have_nerd_font and { + text = { + [vim.diagnostic.severity.ERROR] = '󰅚 ', + [vim.diagnostic.severity.WARN] = '󰀪 ', + [vim.diagnostic.severity.INFO] = '󰋽 ', + [vim.diagnostic.severity.HINT] = '󰌶 ', + }, + } or {}, + virtual_text = { + source = 'if_many', + spacing = 2, + format = function(diagnostic) + local diagnostic_message = { + [vim.diagnostic.severity.ERROR] = diagnostic.message, + [vim.diagnostic.severity.WARN] = diagnostic.message, + [vim.diagnostic.severity.INFO] = diagnostic.message, + [vim.diagnostic.severity.HINT] = diagnostic.message, + } + return diagnostic_message[diagnostic.severity] + end, + }, + } + + -- LSP servers and clients are able to communicate to each other what features they support. + -- By default, Neovim doesn't support everything that is in the LSP specification. + -- When you add blink.cmp, luasnip, etc. Neovim now has *more* capabilities. + -- So, we create new capabilities with blink.cmp, and then broadcast that to the servers. + local capabilities = require('blink.cmp').get_lsp_capabilities() + + local vue_language_server_path = vim.fn.stdpath 'data' .. '/mason/packages/vue-language-server/node_modules/@vue/language-server' + + vim.notify('Setting up Vue Language Server at ' .. vue_language_server_path, vim.log.levels.INFO, { + title = 'Kickstart.nvim', + }) + + local vue_plugin = { + name = '@vue/typescript-plugin', + location = vue_language_server_path, + languages = { 'vue' }, + configNamespace = 'typescript', + } + + vim.lsp.enable 'vtsls' + + vim.lsp.config('vtsls', { + settings = { + vtsls = { + tsserver = { + globalPlugins = { + vue_plugin, + }, + }, + }, + }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, + }) + + -- (Opcional) vue-language-server para otras funcionalidades + vim.lsp.config('vue_ls', {}) + -- Enable the following language servers -- Feel free to add/remove any LSPs that you want here. They will automatically be installed. -- See `:help lsp-config` for information about keys and how to configure @@ -656,8 +754,11 @@ require('lazy').setup({ -- -- You can press `g?` for help in this menu. local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { - -- You can add other tools here that you want Mason to install + 'stylua', -- Used to format Lua code + 'vtsls', -- Vetur Language Server for Vue + 'vue-language-server', -- Vue Language Server }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -707,7 +808,9 @@ require('lazy').setup({ -- python = { "isort", "black" }, -- -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + -- Formato de Vue con prettierd + vue = { 'prettierd' }, }, }, }, @@ -786,7 +889,17 @@ require('lazy').setup({ }, sources = { - default = { 'lsp', 'path', 'snippets' }, + default = { 'lsp', 'path', 'snippets', 'lazydev', 'copilot' }, + providers = { + lazydev = { module = 'lazydev.integrations.blink', score_offset = 100 }, + -- Integración de Copilot con Blink.cmp, para evitar las letras grises + copilot = { + name = 'copilot', + module = 'blink-cmp-copilot', + score_offset = 100, + async = true, + }, + }, }, snippets = { preset = 'luasnip' }, @@ -950,15 +1063,15 @@ require('lazy').setup({ -- require 'kickstart.plugins.debug', -- require 'kickstart.plugins.indent_line', -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommended keymaps + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000000..a7f44a41c5f --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,19 @@ +return { + -- GitHub Copilot backend (sin ghost text ni panel) + { + 'zbirenbaum/copilot.lua', + event = 'InsertEnter', + config = function() + require('copilot').setup { + suggestion = { enabled = false }, -- ✅ no ghost text + panel = { enabled = false }, -- ✅ no panel + } + end, + }, + + -- Integración con blink.cmp + { + 'giuxtaposition/blink-cmp-copilot', + dependencies = { 'zbirenbaum/copilot.lua' }, + }, +} diff --git a/lua/custom/plugins/intelephense.lua b/lua/custom/plugins/intelephense.lua new file mode 100644 index 00000000000..1ed1c0d066e --- /dev/null +++ b/lua/custom/plugins/intelephense.lua @@ -0,0 +1,14 @@ +return { + require('lspconfig').intelephense.setup { + settings = { + intelephense = { + environment = { + phpVersion = '8.3', + }, + files = { + maxSize = 5000000, + }, + }, + }, + }, +} diff --git a/lua/custom/plugins/laravel.lua b/lua/custom/plugins/laravel.lua new file mode 100644 index 00000000000..5fe4ea55bd3 --- /dev/null +++ b/lua/custom/plugins/laravel.lua @@ -0,0 +1,30 @@ +return { + 'adalessa/laravel.nvim', + dependencies = { + 'tpope/vim-dotenv', + 'nvim-telescope/telescope.nvim', + 'MunifTanjim/nui.nvim', + 'kevinhwang91/promise-async', + }, + cmd = { 'Laravel' }, + keys = { + { 'la', ':Laravel artisan' }, + { 'lr', ':Laravel routes' }, + { 'lm', ':Laravel related' }, + { + 'gf', + function() + if require('laravel').app('gf').cursor_on_resource() then + return 'Laravel gf' + else + return 'gf' + end + end, + noremap = false, + expr = true, + }, + }, + event = { 'VeryLazy' }, + opts = {}, + config = true, +} diff --git a/lua/kickstart/plugins/neo-tree.lua b/lua/kickstart/plugins/neo-tree.lua index af8d4495650..ab35be60b34 100644 --- a/lua/kickstart/plugins/neo-tree.lua +++ b/lua/kickstart/plugins/neo-tree.lua @@ -13,7 +13,7 @@ return { }, lazy = false, keys = { - { '\\', ':Neotree reveal', desc = 'NeoTree reveal', silent = true }, + { '', ':Neotree toggle', desc = 'NeoTree toggle', silent = true }, }, ---@module 'neo-tree' ---@type neotree.Config diff --git a/lua/lsp/init.lua b/lua/lsp/init.lua new file mode 100644 index 00000000000..c6870ae3095 --- /dev/null +++ b/lua/lsp/init.lua @@ -0,0 +1,32 @@ +print '✅ lsp/init.lua cargado correctamente' +vim.notify('✅ LSP init.lua cargado', vim.log.levels.INFO) + +local lspconfig = require 'lspconfig' +local capabilities = require('cmp_nvim_lsp').default_capabilities() + +local vue_language_server_path = vim.fn.stdpath 'data' .. '/mason/packages/vue-language-server/node_modules/@vue/language-server' + +local vue_plugin = { + name = '@vue/typescript-plugin', + location = vue_language_server_path, + languages = { 'vue' }, + configNamespace = 'typescript', +} + +lspconfig.vtsls.setup('vtsls', { + settings = { + vtsls = { + tsserver = { + globalPlugins = { + vue_plugin, + }, + }, + }, + }, + filetypes = { 'typescript', 'javascript', 'javascriptreact', 'typescriptreact', 'vue' }, +}) + +-- ✅ (Opcional) vue-language-server para otras funcionalidades +lspconfig.vue_ls.setup { + capabilities = capabilities, +}