From 8a39a1b88a86bbb44dd8b72af6915b52153d5509 Mon Sep 17 00:00:00 2001 From: Henrik Hautakoski Date: Sun, 10 Mar 2024 10:36:20 +0100 Subject: [PATCH] big nvim update. maybe broke something --- nvim/lazy-lock.json | 29 ++-- nvim/lua/config/mappings.lua | 5 +- nvim/lua/config/settings.lua | 9 +- nvim/lua/config/telescope.lua | 2 +- nvim/lua/plugins/dashboard.lua | 27 ---- .../autopairs.lua} | 0 nvim/lua/plugins/{ => editor}/indent.lua | 3 +- .../lua/plugins/{ => editor}/mini-comment.lua | 0 nvim/lua/plugins/{ => editor}/telescope.lua | 22 ++- nvim/lua/plugins/ide/cmp.lua | 133 ++++++++++++++++++ nvim/lua/plugins/ide/dap.lua | 54 +++++++ nvim/lua/plugins/ide/laravel.lua | 17 +++ nvim/lua/plugins/ide/lsp.lua | 47 +++++++ nvim/lua/plugins/{ => ide}/neotest.lua | 18 ++- nvim/lua/plugins/{ => ide}/treesitter.lua | 1 + nvim/lua/plugins/init.lua | 69 +++++---- nvim/lua/plugins/kodex.lua | 7 + nvim/lua/plugins/lsp.lua | 7 - nvim/lua/plugins/nvim-cmp.lua | 70 --------- nvim/lua/plugins/{ => ui}/barbar.lua | 0 nvim/lua/plugins/{ => ui}/colorscheme.lua | 41 +++++- nvim/lua/plugins/ui/dashboard.lua | 42 ++++++ nvim/lua/plugins/ui/dressing.lua | 23 +++ nvim/lua/plugins/{ => ui}/gitsigns.lua | 11 ++ nvim/lua/plugins/{ => ui}/lualine.lua | 0 nvim/lua/plugins/{ => ui}/neo-tree.lua | 0 nvim/lua/plugins/ui/noice.lua | 16 +++ nvim/lua/plugins/ui/which-key.lua | 22 +++ nvim/lua/plugins/which-key.lua | 21 --- nvim/queries/blade/highlights.scm | 9 +- nvim/queries/{php => php_only}/highlights.scm | 12 +- nvim/queries/php_only/indents.scm | 9 ++ 32 files changed, 531 insertions(+), 195 deletions(-) delete mode 100644 nvim/lua/plugins/dashboard.lua rename nvim/lua/plugins/{nvim-autopairs.lua => editor/autopairs.lua} (100%) rename nvim/lua/plugins/{ => editor}/indent.lua (80%) rename nvim/lua/plugins/{ => editor}/mini-comment.lua (100%) rename nvim/lua/plugins/{ => editor}/telescope.lua (53%) create mode 100644 nvim/lua/plugins/ide/cmp.lua create mode 100644 nvim/lua/plugins/ide/dap.lua create mode 100644 nvim/lua/plugins/ide/laravel.lua create mode 100644 nvim/lua/plugins/ide/lsp.lua rename nvim/lua/plugins/{ => ide}/neotest.lua (79%) rename nvim/lua/plugins/{ => ide}/treesitter.lua (99%) create mode 100644 nvim/lua/plugins/kodex.lua delete mode 100644 nvim/lua/plugins/nvim-cmp.lua rename nvim/lua/plugins/{ => ui}/barbar.lua (100%) rename nvim/lua/plugins/{ => ui}/colorscheme.lua (57%) create mode 100644 nvim/lua/plugins/ui/dashboard.lua create mode 100644 nvim/lua/plugins/ui/dressing.lua rename nvim/lua/plugins/{ => ui}/gitsigns.lua (77%) rename nvim/lua/plugins/{ => ui}/lualine.lua (100%) rename nvim/lua/plugins/{ => ui}/neo-tree.lua (100%) create mode 100644 nvim/lua/plugins/ui/noice.lua create mode 100644 nvim/lua/plugins/ui/which-key.lua delete mode 100644 nvim/lua/plugins/which-key.lua rename nvim/queries/{php => php_only}/highlights.scm (57%) create mode 100644 nvim/queries/php_only/indents.scm diff --git a/nvim/lazy-lock.json b/nvim/lazy-lock.json index 20985ad..6601eaf 100644 --- a/nvim/lazy-lock.json +++ b/nvim/lazy-lock.json @@ -4,35 +4,38 @@ "barbar.nvim": { "branch": "master", "commit": "1d6b1386abe97d1d8cba47eb9afa8a9f2d1bbe66" }, "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, - "cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "3d8912ebeb56e5ae08ef0906e3a54de1c66b92f1" }, "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "dashboard": { "branch": "master", "commit": "413442b12d85315fc626c44a0ce4929b213ef604" }, + "dressing.nvim": { "branch": "master", "commit": "6f212262061a2120e42da0d1e87326e8a41c0478" }, "gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, - "go.nvim": { "branch": "master", "commit": "43850d00feb887bc0195fe3331ff6fb76837f8e9" }, - "guihua.lua": { "branch": "master", "commit": "9fb6795474918b492d9ab01b1ebaf85e8bf6fe0b" }, "indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, - "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "laravel.nvim": { "branch": "main", "commit": "5ef5296f9c943e88850591b5e21f17db62e874ee" }, + "lazy.nvim": { "branch": "main", "commit": "83493db50a434a4c5c648faf41e2ead80f96e478" }, "lspkind-nvim": { "branch": "master", "commit": "1735dd5a5054c1fb7feaf8e8658dbab925f4f0cf" }, "lualine-lsp-progress": { "branch": "master", "commit": "56842d097245a08d77912edf5f2a69ba29f275d7" }, - "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "lualine.nvim": { "branch": "master", "commit": "8b56462bfb746760465264de41b4907310f113ec" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, - "neo-tree.nvim": { "branch": "main", "commit": "459c60317cc1d251f6eb3b6f010d015d5d24b806" }, + "neo-tree.nvim": { "branch": "main", "commit": "7f2ebdef3b55374390714ac7c0a7fe6b0dae498a" }, "neotest": { "branch": "master", "commit": "4440cc2227894c2ae9b0673a30e6cc6f1836e8c2" }, "neotest-go": { "branch": "main", "commit": "6a2f996d89fe4631942e035b1c114544ee045043" }, "neotest-phpunit": { "branch": "main", "commit": "2f01e83eedbcf6f0257934b32b5d4fda404a9f11" }, - "nui.nvim": { "branch": "main", "commit": "b81333d12f824dbed5eb231c8a4409a290fdd848" }, + "noice.nvim": { "branch": "main", "commit": "bf67d70bd7265d075191e7812d8eb42b9791f737" }, + "none-ls.nvim": { "branch": "main", "commit": "ff3819c52ca04232fb70fbd6c1639de9abcbe122" }, + "nui.nvim": { "branch": "main", "commit": "756c59f46057cd2d43619cd3a6d4e01b2aa60295" }, "nvim-autopairs": { "branch": "master", "commit": "c6139ca0d5ad7af129ea6c89cb4c56093f2c034a" }, "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, - "nvim-lspconfig": { "branch": "master", "commit": "c932a56bf25167b1e88d2a1ebe35bb774b41019a" }, - "nvim-test": { "branch": "main", "commit": "e06f3d029ee161f3ead6193cf27354d1eb8723c3" }, - "nvim-treesitter": { "branch": "master", "commit": "63ca90eaa3ce1cc668add8828a9e3d6728dbbdf1" }, - "nvim-treesitter-textobjects": { "branch": "master", "commit": "95933e762e28f9d38b572d65e7e4da9d2f4d90cb" }, - "nvim-web-devicons": { "branch": "master", "commit": "4adea17610d140a99c313e3f79a9dc01825d59ae" }, + "nvim-dap": { "branch": "master", "commit": "fc880e82059eb21c0fa896be60146e5f17680648" }, + "nvim-dap-ui": { "branch": "master", "commit": "9720eb5fa2f41988e8770f973cd11b76dd568a5d" }, + "nvim-lspconfig": { "branch": "master", "commit": "16295b79410f131c4fa7870c663b4ace6a761fb2" }, + "nvim-treesitter": { "branch": "master", "commit": "7ff51f53b0efb6228df2e8539b51bb2e737b77f3" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "b7a0bfa3e93697ca5b61b15df633404bf8f45883" }, + "nvim-web-devicons": { "branch": "master", "commit": "75df79feb02d5e0ec114e447453775d4d291ea03" }, "onedark.nvim": { "branch": "master", "commit": "1230aaf2a427b2c5b73aba6e4a9a5881d3e69429" }, "playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, - "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "plenary.nvim": { "branch": "master", "commit": "f7adfc4b3f4f91aab6caebf42b3682945fbc35be" }, "telescope.nvim": { "branch": "master", "commit": "7011eaae0ac1afe036e30c95cf80200b8dc3f21a" }, + "vim-dotenv": { "branch": "master", "commit": "5c51cfcf8d87280d6414e03cd6b253eb70ecb800" }, "which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" } } \ No newline at end of file diff --git a/nvim/lua/config/mappings.lua b/nvim/lua/config/mappings.lua index 2f29fa3..15571ff 100644 --- a/nvim/lua/config/mappings.lua +++ b/nvim/lua/config/mappings.lua @@ -37,10 +37,13 @@ map("n", "bb", cmd.bp, { silent = true, desc = "Move to previous buffer" map("n", "bd", cmd.bd, { silent = true, desc = "Close current buffer"}) -- Indent -map('n', "", "v=") +map('n', "", "^=$") map('x', "", "=", { desc = "auto indent selection" }) map("i", "", "", { desc = "delete indent" }) +-- fix paste +map('n', "p", "p=$") + -- Crazy search+replace map("n", "rw", [[:%s/\<\>//gI]], { desc = "search+replace word under cursor" diff --git a/nvim/lua/config/settings.lua b/nvim/lua/config/settings.lua index 52d09cd..095016c 100644 --- a/nvim/lua/config/settings.lua +++ b/nvim/lua/config/settings.lua @@ -10,7 +10,7 @@ set.showmode = false -- disable mode in the command line, because i use lualine -- -- Editor settings -- - +set.pumheight = 20 set.hlsearch = false set.incsearch = true set.laststatus = 3 @@ -38,3 +38,10 @@ vim.filetype.add({ }, }) +-- Sign configuration +local icons = require('config.icons').diagnostics +vim.fn.sign_define('DiagnosticSignError', { text = icons.error, texthl = 'DiagnosticSignError' }) +vim.fn.sign_define('DiagnosticSignWarn', { text = icons.warn, texthl = 'DiagnosticSignWarn' }) +vim.fn.sign_define('DiagnosticSignInfo', { text = icons.info, texthl = 'DiagnosticSignInfo' }) +vim.fn.sign_define('DiagnosticSignHint', { text = icons.hint, texthl = 'DiagnosticSignHint' }) + diff --git a/nvim/lua/config/telescope.lua b/nvim/lua/config/telescope.lua index c71febc..5af1cda 100644 --- a/nvim/lua/config/telescope.lua +++ b/nvim/lua/config/telescope.lua @@ -2,12 +2,12 @@ return { { 'sf', 'Telescope find_files', desc = 'Search files' }, { 'sa', 'Telescope live_grep', desc = 'Search in files' }, { 'sg', 'Telescope git_files', desc = 'Search Git files' }, + { 'so', 'Telescope oldfiles', desc = 'Search Old files' }, { 'sw', 'Telescope grep_string', desc = 'Search for word under cursor' }, -- LSP { 'sr', 'Telescope lsp_references', desc = 'Search Reference' }, { 'ss', 'Telescope lsp_document_symbols', desc = 'Search document symbols' }, { 'sr', 'Telescope lsp_references', desc = 'Search Reference' }, - { 'sr', 'Telescope lsp_references', desc = 'Search Reference' }, { 'gd', 'Telescope lsp_definitions', desc = 'Goto definition' }, } diff --git a/nvim/lua/plugins/dashboard.lua b/nvim/lua/plugins/dashboard.lua deleted file mode 100644 index 08470ad..0000000 --- a/nvim/lua/plugins/dashboard.lua +++ /dev/null @@ -1,27 +0,0 @@ -return { - 'nvimdev/dashboard-nvim', - name = 'dashboard', - dependencies = { - 'nvim-tree/nvim-web-devicons' - }, - event = 'VimEnter', - opts = { - config = { - header = { - '::::::::: :::: ::: ::: :::', - ':+: :+: :+:+: :+: :+: :+:', - '+:+ +:+ :+:+:+ +:+ +:+ +:+ ', - '+#++:++#+ +#+ +:+ +#+ +#++:+ ', - '+#+ +#+ +#+#+# +#+ +#+ ', - '#+# #+# #+#+# #+# #+#', - '### ### #### ### ###', - '', - }, - shortcut = { - { desc = '󰊳 Update', group = '@property', action = 'Lazy update', key = 'u' } - }, - footer = {} - } - } -} - diff --git a/nvim/lua/plugins/nvim-autopairs.lua b/nvim/lua/plugins/editor/autopairs.lua similarity index 100% rename from nvim/lua/plugins/nvim-autopairs.lua rename to nvim/lua/plugins/editor/autopairs.lua diff --git a/nvim/lua/plugins/indent.lua b/nvim/lua/plugins/editor/indent.lua similarity index 80% rename from nvim/lua/plugins/indent.lua rename to nvim/lua/plugins/editor/indent.lua index b759c06..30de37e 100644 --- a/nvim/lua/plugins/indent.lua +++ b/nvim/lua/plugins/editor/indent.lua @@ -4,7 +4,8 @@ return{ opts = { scope = { enabled = true, - show_exact_scope = true, + show_start = false, + show_end = false }, exclude = { filetypes = { diff --git a/nvim/lua/plugins/mini-comment.lua b/nvim/lua/plugins/editor/mini-comment.lua similarity index 100% rename from nvim/lua/plugins/mini-comment.lua rename to nvim/lua/plugins/editor/mini-comment.lua diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/editor/telescope.lua similarity index 53% rename from nvim/lua/plugins/telescope.lua rename to nvim/lua/plugins/editor/telescope.lua index cb32001..c301d83 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/editor/telescope.lua @@ -6,7 +6,16 @@ return { main = 'telescope', dependencies = { 'nvim-lua/plenary.nvim', - 'nvim-tree/nvim-web-devicons' + 'nvim-tree/nvim-web-devicons', + { + "folke/which-key.nvim", + -- optional = true, + opts = { + defaults = { + ["s"] = { name = "+search" }, + }, + }, + }, }, keys = require('config.telescope'), opts = function() @@ -14,6 +23,17 @@ return { return { defaults = { path_display = { truncate = 1 }, + -- borderchars = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + border = { + prompt = { 1, 1, 1, 1 }, + results = { 1, 1, 1, 1 }, + preview = { 1, 1, 1, 1 }, + }, + borderchars = { + prompt = { "─", "│", "─", "│", "├", "┤", "┴", "└" }, + results = { "─", "│", " ", "│", "┌", "┬", "│", "│" }, + preview = { "─", "│", "─", " ", "─", "┐", "┘", "─" }, + }, prompt_prefix = ' ' .. icons.prompt .. ' ', selection_caret = icons.current .. ' ', multi_icon = icons.selected .. ' ', diff --git a/nvim/lua/plugins/ide/cmp.lua b/nvim/lua/plugins/ide/cmp.lua new file mode 100644 index 0000000..d02ee20 --- /dev/null +++ b/nvim/lua/plugins/ide/cmp.lua @@ -0,0 +1,133 @@ +return { + 'hrsh7th/nvim-cmp', + version = false, + event = "InsertEnter", + dependencies = { + 'hrsh7th/cmp-buffer', + 'hrsh7th/cmp-path', + 'hrsh7th/cmp-nvim-lsp', + 'L3MON4D3/LuaSnip', + 'onsails/lspkind-nvim', + }, + opts = function() + local cmp = require('cmp') + vim.api.nvim_set_hl(0, "CmpGhostText", { link = "NonText", default = true }) + + local selectPrev = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }) + local selectNext = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }) + + local border = cmp.config.window.bordered({ + border = {'┌', '─', '┐', '│', '┘', '─', '└', '│'}, + winhighlight = 'Normal:None,FloatBorder:FloatBorder,CursorLine:PmenuSel,Search:None' + }) + + return { + completion = { + completeopt = "menu,menuone,noinsert", + }, + -- enabled = function() + -- if require"cmp.config.context".in_treesitter_capture("comment")==true or require"cmp.config.context".in_syntax_group("Comment") then + -- return false + -- else + -- return true + -- end + -- end, + -- preselect = false, + view = { + entries = { name = 'custom', selection_order = 'near_cursor' }, + }, + window = { + documentation = border, + completion = border + }, + mapping = { + [""] = selectPrev, + [""] = selectPrev, + [""] = selectNext, + [""] = selectNext, + -- [""] = close without removeing typed text, + [""] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), + }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + -- formatting = { + -- fields = { "abbr", "menu", "kind" }, + -- format = function(entry, vim_item) + -- if vim.tbl_contains({ 'path' }, entry.source.name) then + -- local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label) + -- if icon then + -- vim_item.kind = icon + -- vim_item.kind_hl_group = hl_group + -- return vim_item + -- end + -- end + -- + -- local opts = { + -- mode = 'symbol', + -- } + -- return require('lspkind').cmp_format(opts)(entry, vim_item) + -- end + -- }, + sources = { + { name = 'nvim_lsp' }, + { name = 'buffer' }, + { name = 'path' }, + { name = 'luasnip' } + }, + experimental = { + ghost_text = { + hl_group = "CmpGhostText", + }, + }, + } + end, + config = function(_, opts) + local cmp = require('cmp') + + -- local has_words_before = function() + -- local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + -- return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + -- end + + -- local moveDown = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_next_item() + -- elseif has_words_before() then + -- cmp.complete() + -- else + -- fallback() + -- end + -- end, { "i", "s" }) + -- + -- local moveUp = cmp.mapping(function(fallback) + -- if cmp.visible() then + -- cmp.select_prev_item() + -- else + -- fallback() + -- end + -- end, { "i", "s" }) + + cmp.setup(opts) + + vim.lsp.handlers['textDocument/hover'] = vim.lsp.with( + vim.lsp.handlers.hover, + {border = 'single'} + ) + + vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, { + focusable = true, + style = "minimal", + border = "single", + }) + + -- insert () on function completion using autopairs + cmp.event:on( + 'confirm_done', + require('nvim-autopairs.completion.cmp').on_confirm_done() + ) + end +} diff --git a/nvim/lua/plugins/ide/dap.lua b/nvim/lua/plugins/ide/dap.lua new file mode 100644 index 0000000..04cc9e8 --- /dev/null +++ b/nvim/lua/plugins/ide/dap.lua @@ -0,0 +1,54 @@ +return { + "mfussenegger/nvim-dap", + dependencies = { + { + "folke/which-key.nvim", + -- optional = true, + opts = { + defaults = { + ["d"] = { name = "+debug" }, + }, + }, + }, + { + "rcarriga/nvim-dap-ui", + -- stylua: ignore + keys = { + { "du", function() require("dapui").toggle({ }) end, desc = "Dap UI" }, + { "de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} }, + }, + opts = {}, + config = function(_, opts) + -- setup dap config by VsCode launch.json file + -- require("dap.ext.vscode").load_launchjs() + local dap = require("dap") + local dapui = require("dapui") + dapui.setup(opts) + dap.listeners.after.event_initialized["dapui_config"] = function() + dapui.open({}) + end + dap.listeners.before.event_terminated["dapui_config"] = function() + dapui.close({}) + end + dap.listeners.before.event_exited["dapui_config"] = function() + dapui.close({}) + end + end, + }, + }, + keys = { + { "dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" }, + }, + config = function() + -- local Config = require("lazyvim.config") + vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" }) + + -- for name, sign in pairs(Config.icons.dap) do + -- sign = type(sign) == "table" and sign or { sign } + -- vim.fn.sign_define( + -- "Dap" .. name, + -- { text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] } + -- ) + -- end + end, +} diff --git a/nvim/lua/plugins/ide/laravel.lua b/nvim/lua/plugins/ide/laravel.lua new file mode 100644 index 0000000..5d15a6b --- /dev/null +++ b/nvim/lua/plugins/ide/laravel.lua @@ -0,0 +1,17 @@ +return { + "adalessa/laravel.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + "tpope/vim-dotenv", + "MunifTanjim/nui.nvim", + "nvimtools/none-ls.nvim", + }, + cmd = { "Sail", "Artisan", "Composer", "Npm", "Yarn", "Laravel" }, + keys = { + { "la", ":Laravel artisan" }, + { "lr", ":Laravel routes" }, + { "lm", ":Laravel related" }, + }, + event = { "VeryLazy" }, + config = true, +} diff --git a/nvim/lua/plugins/ide/lsp.lua b/nvim/lua/plugins/ide/lsp.lua new file mode 100644 index 0000000..ae68078 --- /dev/null +++ b/nvim/lua/plugins/ide/lsp.lua @@ -0,0 +1,47 @@ +return { + 'neovim/nvim-lspconfig', + dependencies = { + 'williamboman/mason.nvim', + 'williamboman/mason-lspconfig.nvim', + 'hrsh7th/cmp-nvim-lsp', + }, + opts = { + mappings = { + ["rs"] = { vim.lsp.buf.rename, { desc = "Rename symbol" }} + }, + servers = { + phpactor = { + init_options = { + ["language_server_phpstan.enabled"] = true, + ["language_server_psalm.enabled"] = false, + } + }, + gopls = {} + }, + }, + config = function (_, opts) + -- Setup Mason to automatically install LSP servers + require('mason').setup() + require('mason-lspconfig').setup({ automatic_installation = true }) + local lspconfig = require('lspconfig') + local capabilities = require('cmp_nvim_lsp').default_capabilities() + capabilities.textDocument.completion.completionItem.snippetSupport = false + + local on_attach = function(ev) + for bind, settings in pairs(opts.mappings) do + vim.keymap.set('n', bind, settings[0], vim.tbl_deep_extend("force", settings[1], { buffer = ev.buf })) + end + + -- vim.keymap.set('n', 'rs', vim.lsp.buf.rename, { buffer = ev.buf, desc = "Rename symbol" }) + end + + for name, settings in pairs(opts.servers) do + + settings = vim.tbl_deep_extend("force", settings, { + capabilities = capabilities, + on_attach = on_attach + }) + lspconfig[name].setup(settings) + end + end +} diff --git a/nvim/lua/plugins/neotest.lua b/nvim/lua/plugins/ide/neotest.lua similarity index 79% rename from nvim/lua/plugins/neotest.lua rename to nvim/lua/plugins/ide/neotest.lua index 59fe0c0..c3909dd 100644 --- a/nvim/lua/plugins/neotest.lua +++ b/nvim/lua/plugins/ide/neotest.lua @@ -5,14 +5,24 @@ return { "antoinemadec/FixCursorHold.nvim", "nvim-treesitter/nvim-treesitter", "nvim-neotest/neotest-go", - "olimorris/neotest-phpunit" + "olimorris/neotest-phpunit", + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["t"] = { name = "+test" }, + }, + }, + }, }, keys = { - {"tn", ":lua require('neotest').run.run()", desc = "test nearest"}, + {"tn", ":lua require('neotest').run.run()", desc = "test nearest", silent = true}, {"tf", ":lua require('neotest').run.run(vim.fn.expand('%'))", desc = "test file"}, {"ta", ":lua require('neotest').output_panel.open():lua require('neotest').run.run({suite = true})", desc = "test all"}, {"ts", ":lua require('neotest').run.stop()", desc = "stop test"}, {"tq", ":lua require('neotest').output_panel.close()", desc = "close output window"}, + {"te", ":lua require('neotest').summary()"} }, opts = function() local icons = require('config.icons').test @@ -28,10 +38,10 @@ return { child_indent = "│", child_prefix = "├", collapsed = "─", - expanded = "╮", + expanded = "┐", failed = icons.failed, final_child_indent = " ", - final_child_prefix = "╰", + final_child_prefix = "└", non_collapsible = "─", passed = icons.ok, running = icons.running, diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/ide/treesitter.lua similarity index 99% rename from nvim/lua/plugins/treesitter.lua rename to nvim/lua/plugins/ide/treesitter.lua index b8ecc5a..ee6713b 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/ide/treesitter.lua @@ -21,6 +21,7 @@ return { "vimdoc", "query", "php", + "phpdoc", "blade", "go", "javascript", diff --git a/nvim/lua/plugins/init.lua b/nvim/lua/plugins/init.lua index 694bec2..43c48b5 100644 --- a/nvim/lua/plugins/init.lua +++ b/nvim/lua/plugins/init.lua @@ -11,44 +11,43 @@ if not vim.loop.fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) +local opts = { + dev = { + path = "~/code/nvim_plugins", + } +} + require("lazy").setup({ - { import = "plugins.dashboard" }, + -- Editor + -------------------- + { import = "plugins.editor.indent" }, + { import = "plugins.editor.autopairs" }, + { import = "plugins.editor.mini-comment" }, + { import = "plugins.editor.telescope" }, - -- Highlight - { import = "plugins.colorscheme" }, + -- UI + -------------------- + { import = "plugins.ui.dressing" }, + { import = "plugins.ui.noice" }, + { import = "plugins.ui.dashboard" }, + { import = "plugins.ui.colorscheme" }, + { import = "plugins.ui.neo-tree" }, + { import = "plugins.ui.barbar" }, + { import = "plugins.ui.lualine" }, + { import = "plugins.ui.gitsigns" }, + { import = "plugins.ui.which-key" }, - { import = "plugins.indent" }, - { import = "plugins.nvim-autopairs" }, - { import = "plugins.mini-comment" }, - { import = "plugins.barbar" }, + -- IDE + -------------------- + { import = "plugins.ide.treesitter" }, + { import = "plugins.ide.cmp" }, + { import = "plugins.ide.lsp" }, + { import = "plugins.ide.dap" }, + { import = "plugins.ide.neotest" }, + { import = "plugins.ide.laravel" } + -- { import = "plugins.nvim-test" }, - -- Filetree - { import = "plugins.neo-tree" }, - - -- Status line - { import = "plugins.lualine" }, - - -- Fuzzy finder - { import = "plugins.telescope" }, - - -- Keybind helper - { import = "plugins.which-key" }, - - -- Treesitter - { import = "plugins.treesitter" }, - - { import = "plugins.neotest" }, - - -- LSP - { import = "plugins.lsp" }, - { import = "plugins.nvim-cmp" }, - - { import = "plugins.go" }, - - { import = "plugins.nvim-test" }, - - -- Git changes in gutter - { import = "plugins.gitsigns" }, -}) + -- { import = "plugins.go" }, +}, opts) diff --git a/nvim/lua/plugins/kodex.lua b/nvim/lua/plugins/kodex.lua new file mode 100644 index 0000000..042dbf7 --- /dev/null +++ b/nvim/lua/plugins/kodex.lua @@ -0,0 +1,7 @@ +return { + "pnx/kodex.nvim", + dev = true, + config = function() + require('kodex').load() + end +} diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index 7708a0d..ca93342 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -73,12 +73,5 @@ return { capabilities = capabilities }) - -- Config - -- Sign configuration - local icons = require('config.icons').diagnostics - vim.fn.sign_define('DiagnosticSignError', { text = icons.error, texthl = 'DiagnosticSignError' }) - vim.fn.sign_define('DiagnosticSignWarn', { text = icons.warn, texthl = 'DiagnosticSignWarn' }) - vim.fn.sign_define('DiagnosticSignInfo', { text = icons.info, texthl = 'DiagnosticSignInfo' }) - vim.fn.sign_define('DiagnosticSignHint', { text = icons.hint, texthl = 'DiagnosticSignHint' }) end } diff --git a/nvim/lua/plugins/nvim-cmp.lua b/nvim/lua/plugins/nvim-cmp.lua deleted file mode 100644 index ac86df5..0000000 --- a/nvim/lua/plugins/nvim-cmp.lua +++ /dev/null @@ -1,70 +0,0 @@ -return { - 'hrsh7th/nvim-cmp', - dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-nvim-lsp-signature-help', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'L3MON4D3/LuaSnip', - 'onsails/lspkind-nvim', - }, - config = function() - local cmp = require('cmp') - - local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil - end - - local moveDown = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }) - - local moveUp = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }) - - cmp.setup({ - preselect = false, - view = { - entries = { name = 'custom', selection_order = 'near_cursor' }, - }, - mapping = { - [""] = moveDown, - [""] = moveDown, - [""] = moveUp, - [""] = moveUp, - [''] = cmp.mapping.confirm({ select = true }), - }, - formatting = { - format = function(entry, vim_item) - if vim.tbl_contains({ 'path' }, entry.source.name) then - local icon, hl_group = require('nvim-web-devicons').get_icon(entry:get_completion_item().label) - if icon then - vim_item.kind = icon - vim_item.kind_hl_group = hl_group - return vim_item - end - end - return require('lspkind').cmp_format({ with_text = true })(entry, vim_item) - end - }, - sources = { - { name = 'nvim_lsp', max_item_count = 10 }, - { name = 'nvim_lsp_signature_help' }, - { name = 'buffer' }, - { name = 'path' }, - }, - }) - end -} diff --git a/nvim/lua/plugins/barbar.lua b/nvim/lua/plugins/ui/barbar.lua similarity index 100% rename from nvim/lua/plugins/barbar.lua rename to nvim/lua/plugins/ui/barbar.lua diff --git a/nvim/lua/plugins/colorscheme.lua b/nvim/lua/plugins/ui/colorscheme.lua similarity index 57% rename from nvim/lua/plugins/colorscheme.lua rename to nvim/lua/plugins/ui/colorscheme.lua index 0519857..5999be3 100644 --- a/nvim/lua/plugins/colorscheme.lua +++ b/nvim/lua/plugins/ui/colorscheme.lua @@ -16,16 +16,34 @@ return { bg0 = '#282a33', bg1 = '#30323b', bg2 = '#24262f', + bg3 = '#383a43', bg_d = "#1f2129", + bg_blue = "#ff00ff", + bg_yellow = "#f0d197", red = '#cc817f', green = '#7ccfaf', yellow = '#ffcc99', orange = '#ffcc99', blue = '#8ac6f2', cyan = '#8abeb7', - purple = '#9999cc' + purple = '#9999cc', + dark_cyan = "#8abeb7", + dark_red = "#cc817f", + dark_yellow = "#ffcc99", + dark_purple = "#9999cc", }, highlights = { + -- ColorColumn = { bg = "$bg2"}, + -- SignColumn = { bg = "$bg2"}, + -- LineNr = { fg = "$light_grey", bg = "$bg2" } + LineNr = { fg = "$light_grey" }, + CursorLineNr = { fg = "$blue" }, + + Pmenu = { bg = "$bg2"}, + PmenuSel = { bg = "$bg_d", fg = "$fg" }, + FloatBorder = { fg = "$grey", bg = 'None' }, + -- Syntax + ["@comment"] = { fg = "$red" }, ["@string"] = { fg = "$purple" }, ["@function"] = { fg = "$fg" }, ["@keyword"] = { fg = "$yellow" }, @@ -33,19 +51,36 @@ return { ["@keyword.function"] = { fg = "$yellow" }, ["@keyword.conditional"] = { fg = "$yellow" }, ["@keyword.operator"] = { fg = "$yellow" }, + ["@keyword.repeat"] = { fg = "$yellow" }, + ["@constant"] = { fg = "$green" }, + ["@tag"] = { fg = "$yellow" }, + ["@tag.delimiter"] = { fg = "$yellow" }, + ["@tag.attribute"] = { fg = "$cyan" }, ["@type"] = { fg = "$blue" }, ["@type.qualifier"] = { fg = "$yellow" }, ["@type.definition"] = { fg = "$blue" }, ["@type.builtin"] = { fg = "$blue" }, ["@function.method"] = { fg = "$fg" }, + ["@function.call"] = { fg = "$fg" }, + ["@function.builtin"] = { fg = "$fg" }, + ["@number"] = { fg = "$red" }, ["@variable"] = { fg = "$green" }, + ["@variable.member"] = { fg = "$green" }, ["@variable.builtin"] = { fg = "$green" }, ["@variable.parameter"] = { fg = "$fg" }, - ["@property"] = { fg = "$green" }, + ["@property"] = { fg = "$orange" }, + -- ["@property"] = { fg = "$fg" }, ["@punctuation.delimiter"] = { fg = "$fg" }, ["@punctuation.bracket"] = { fg = "$fg" }, ["@module"] = { fg = "$fg" }, + + -- php overrides + ["@class_name.php"] = { fg = "$fg" }, + ["@extend_name.php"] = { fg = "$fg" }, + ["@implements_name.php"] = { fg = "$fg" }, + ["@namespace_name.php"] = { fg = "$fg" }, + ["@namespace_alias.php"] = { fg = "$fg" }, } }, config = function(_, opts) @@ -56,6 +91,6 @@ return { vim.cmd(string.format("highlight GitSignsAdd guifg='%s'", opts.colors.green)) vim.cmd(string.format("highlight GitSignsChange guifg='%s'", opts.colors.yellow)) vim.cmd(string.format("highlight GitSignsDelete guifg='%s'", opts.colors.red)) - -- vim.api.nvim_command("highlight GitSign" + end } diff --git a/nvim/lua/plugins/ui/dashboard.lua b/nvim/lua/plugins/ui/dashboard.lua new file mode 100644 index 0000000..4873752 --- /dev/null +++ b/nvim/lua/plugins/ui/dashboard.lua @@ -0,0 +1,42 @@ + +local logo = [[ + ::::::::: :::: ::: ::: ::: + :+: :+: :+:+: :+: :+: :+: + +:+ +:+ :+:+:+ +:+ +:+ +:+ + +#++:++#+ +#+ +:+ +#+ +#++:+ + +#+ +#+ +#+#+# +#+ +#+ + #+# #+# #+#+# #+# #+# + ### ### #### ### ### +]] + +logo = string.rep("\n", 8) .. logo .. "\n\n" + +return { + 'nvimdev/dashboard-nvim', + name = 'dashboard', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + event = 'VimEnter', + opts = { + theme = 'doom', + config = { + header = vim.split(logo, "\n"), + + center = { + { action = function() require('telescope.builtin').find_files() end, desc = " Find file", icon = " ", key = "f" }, + { action = "ene | startinsert", desc = " New file", icon = " ", key = "n" }, + { action = function() require('telescope.builtin').oldfiles() end, desc = " Recent files", icon = " ", key = "r" }, + { action = function() require('telescope.builtin').live_grep() end, desc = " Find text", icon = " ", key = "g" }, + { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, + { action = "qa", desc = " Quit", icon = " ", key = "q" } + }, + footer = function() + local stats = require("lazy").stats() + local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) + return { "Loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" } + end, + } + } +} + diff --git a/nvim/lua/plugins/ui/dressing.lua b/nvim/lua/plugins/ui/dressing.lua new file mode 100644 index 0000000..db9951a --- /dev/null +++ b/nvim/lua/plugins/ui/dressing.lua @@ -0,0 +1,23 @@ +return { + 'stevearc/dressing.nvim', + opts = { + input = { + title_pos = "center", + border = "single", + relative = "win", + }, + select = { + backend = { "telescope", "builtin" }, + telescope = require('telescope.themes').get_dropdown({ + borderchars = { + prompt = { "─", "│", "─", "│", "┌", "┐", "┘", "└" }, + results = { "─", "│", "─", "│", "├", "┤", "┘", "└" }, + }, + max_height = 5 + }), + builtin = { + border = "single", + } + } + }, +} diff --git a/nvim/lua/plugins/gitsigns.lua b/nvim/lua/plugins/ui/gitsigns.lua similarity index 77% rename from nvim/lua/plugins/gitsigns.lua rename to nvim/lua/plugins/ui/gitsigns.lua index 874727c..51699cf 100644 --- a/nvim/lua/plugins/gitsigns.lua +++ b/nvim/lua/plugins/ui/gitsigns.lua @@ -2,6 +2,17 @@ local icons = require('config.icons').diff_gutter return { 'lewis6991/gitsigns.nvim', + dependencies = { + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["g"] = { name = "+git" }, + }, + }, + }, + }, lazy = false, keys = { { 'gp', 'Gitsigns preview_hunk', desc = 'Git preview diff' }, diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/ui/lualine.lua similarity index 100% rename from nvim/lua/plugins/lualine.lua rename to nvim/lua/plugins/ui/lualine.lua diff --git a/nvim/lua/plugins/neo-tree.lua b/nvim/lua/plugins/ui/neo-tree.lua similarity index 100% rename from nvim/lua/plugins/neo-tree.lua rename to nvim/lua/plugins/ui/neo-tree.lua diff --git a/nvim/lua/plugins/ui/noice.lua b/nvim/lua/plugins/ui/noice.lua new file mode 100644 index 0000000..940f369 --- /dev/null +++ b/nvim/lua/plugins/ui/noice.lua @@ -0,0 +1,16 @@ +return { + "folke/noice.nvim", + event = "VeryLazy", + opts = { + cmdline = { + view = "cmdline" + }, + presets = { + bottom_search = true, + command_palette = true + } + }, + dependencies = { + "MunifTanjim/nui.nvim", + } +} diff --git a/nvim/lua/plugins/ui/which-key.lua b/nvim/lua/plugins/ui/which-key.lua new file mode 100644 index 0000000..77302af --- /dev/null +++ b/nvim/lua/plugins/ui/which-key.lua @@ -0,0 +1,22 @@ +return { + "folke/which-key.nvim", + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = { + defaults = { + mode = { "n", "v" }, + ["r"] = { name = "+rename" }, + ["b"] = { name = "+buffers" }, + ["f"] = { name = "+files" }, + } + }, + config = function(_, opts) + local wk = require("which-key") + wk.setup(opts) + wk.register(opts.defaults) + end +} + diff --git a/nvim/lua/plugins/which-key.lua b/nvim/lua/plugins/which-key.lua deleted file mode 100644 index 3c74157..0000000 --- a/nvim/lua/plugins/which-key.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - "folke/which-key.nvim", - event = "VeryLazy", - init = function() - vim.o.timeout = true - vim.o.timeoutlen = 300 - end, - opts = {}, - config = function() - local wk = require("which-key") - - wk.register({ - f = 'file', - b = 'buffers', - t = 'test', - g = 'git', - s = 'search' - }, { prefix = "" }) - end -} - diff --git a/nvim/queries/blade/highlights.scm b/nvim/queries/blade/highlights.scm index 27ae020..5c206f5 100644 --- a/nvim/queries/blade/highlights.scm +++ b/nvim/queries/blade/highlights.scm @@ -1,5 +1,6 @@ -(directive) @keyword -(directive_start) @keyword -(directive_end) @keyword (comment) @comment -(keyword) @keyword +((parameter) @string (#set! "priority" 110)) +((php_only) @include (#set! "priority" 110)) +((bracket_start) @function (#set! "priority" 120)) +((bracket_end) @function (#set! "priority" 120)) +((keyword) @keyword (#set! "priority" 110)) diff --git a/nvim/queries/php/highlights.scm b/nvim/queries/php_only/highlights.scm similarity index 57% rename from nvim/queries/php/highlights.scm rename to nvim/queries/php_only/highlights.scm index f023f49..c7c4539 100644 --- a/nvim/queries/php/highlights.scm +++ b/nvim/queries/php_only/highlights.scm @@ -5,9 +5,9 @@ ; Tag names in class definition as regular text. (class_declaration [ - name: (name) @text - (base_clause (name) @text) - (class_interface_clause (name) @text) + name: (name) @class_name + (base_clause (name) @extend_name) + (class_interface_clause (name) @implement_name) ]) ; tag "use" traits as text @@ -16,8 +16,8 @@ ; tag namespace classes in "use" as text (namespace_use_declaration (namespace_use_clause [ (qualified_name [ - (name) @text - (namespace_name_as_prefix (namespace_name (name) @text)) + (name) @namespace_name + (namespace_name_as_prefix (namespace_name (name) @namespace_name)) ]) - (namespace_aliasing_clause (name) @text) + (namespace_aliasing_clause (name) @namespace_alias) ])) diff --git a/nvim/queries/php_only/indents.scm b/nvim/queries/php_only/indents.scm new file mode 100644 index 0000000..d09df03 --- /dev/null +++ b/nvim/queries/php_only/indents.scm @@ -0,0 +1,9 @@ +; extends + +; Fix for phpdoc comments that don't align * properly. +; This is black magic. I came up with it myself but +; i don't know why it works. +(ERROR + "/" + "**" + @indent.align)