From 7152b5c26fbbfc4e84d8ccfa6917ca71fab14cc5 Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Thu, 7 Sep 2023 17:32:59 +0200 Subject: updates and improvements --- lua/alpha/lsp/attach.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ lua/alpha/lsp/null-ls.lua | 16 ++++++++-------- lua/alpha/lsp/servers.lua | 16 ++++++++++++++-- lua/plugins/direnv.lua | 5 +++++ lua/plugins/neotest.lua | 10 ++++++---- 5 files changed, 78 insertions(+), 14 deletions(-) create mode 100644 lua/plugins/direnv.lua (limited to 'lua') diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua index e15ad92..6fc415c 100644 --- a/lua/alpha/lsp/attach.lua +++ b/lua/alpha/lsp/attach.lua @@ -5,6 +5,51 @@ local filetype_attach = setmetatable({ vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorReindex", function() vim.lsp.buf_notify(bufnr, "phpactor/index/reindex", {}) end, {}) + + vim.api.nvim_buf_create_user_command(bufnr, 'LspPhpactorStatus', function() + local results, _ = vim.lsp.buf_request_sync(bufnr, "phpactor/status", {["return"]=true}) + + local content = '' + + for _, res in pairs(results or {}) do + if res ~= nil and res["result"] ~= nil then + content = content .. res["result"] + end + end + + + local Popup = require("nui.popup") + local event = require("nui.utils.autocmd").event + + local popup = Popup({ + enter = true, + focusable = true, + border = { + style = "rounded", + }, + position = "50%", + size = { + width = "80%", + height = "60%", + }, + }) + + -- mount/open the component + popup:mount() + + -- unmount component when cursor leaves buffer + popup:on(event.BufLeave, function() + popup:unmount() + end) + local out = {}; + for match in string.gmatch(content, "[^\n]+") do + table.insert(out, match); + end + + vim.api.nvim_buf_set_option(popup.bufnr, "filetype", "markdown") + vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, out) + + end, {}) end, }, { __index = function() diff --git a/lua/alpha/lsp/null-ls.lua b/lua/alpha/lsp/null-ls.lua index 3428ec6..b329ba6 100644 --- a/lua/alpha/lsp/null-ls.lua +++ b/lua/alpha/lsp/null-ls.lua @@ -16,14 +16,14 @@ null_ls.setup { -- php_actions.getter_setter, -- php_actions.file_creator, - null_ls.builtins.diagnostics.phpstan.with { - to_temp_file = false, - method = null_ls.methods.DIAGNOSTICS_ON_SAVE, - -- command = "./bin/phpstan", - -- condition = function () - -- return vim.fn.findfile("bin/phpstan") ~= "" - -- end - }, + -- null_ls.builtins.diagnostics.phpstan.with { + -- to_temp_file = false, + -- method = null_ls.methods.DIAGNOSTICS_ON_SAVE, + -- -- command = "./bin/phpstan", + -- -- condition = function () + -- -- return vim.fn.findfile("bin/phpstan") ~= "" + -- -- end + -- }, null_ls.builtins.diagnostics.phpcs.with { method = null_ls.methods.DIAGNOSTICS_ON_SAVE, condition = function(utils) diff --git a/lua/alpha/lsp/servers.lua b/lua/alpha/lsp/servers.lua index 14ec9d3..c849c13 100644 --- a/lua/alpha/lsp/servers.lua +++ b/lua/alpha/lsp/servers.lua @@ -12,6 +12,18 @@ local default = function() end return { + -- ["cucumber_language_server"] = function() + -- return { + -- on_attach = lsp_attach, + -- flags = lsp_flags, + -- settings = { + -- cucumber = { + -- features = { "tests/Behat/features/*.feature" }, + -- glue = { "tests/Behat/*.php" }, + -- }, + -- }, + -- } + -- end, ["emmet_ls"] = function() local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) @@ -78,7 +90,7 @@ return { end, ["omnisharp"] = function() return { - cmd = {"OmniSharp"}, + cmd = { "OmniSharp" }, on_attach = lsp_attach, flags = lsp_flags, } @@ -88,7 +100,7 @@ return { return { on_attach = lsp_attach, flags = lsp_flags, - filetypes = { "php", "cucumber" }, + filetypes = { "php" }, init_options = { ["language_server_worse_reflection.inlay_hints.enable"] = true, ["language_server_worse_reflection.inlay_hints.params"] = true, diff --git a/lua/plugins/direnv.lua b/lua/plugins/direnv.lua new file mode 100644 index 0000000..df3d01d --- /dev/null +++ b/lua/plugins/direnv.lua @@ -0,0 +1,5 @@ +return { + "direnv/direnv.vim", + lazy = false, + priority = 900, +} diff --git a/lua/plugins/neotest.lua b/lua/plugins/neotest.lua index 00ed18d..09e99b0 100644 --- a/lua/plugins/neotest.lua +++ b/lua/plugins/neotest.lua @@ -1,6 +1,7 @@ return { "nvim-neotest/neotest", - enabled = false, + enabled = true, + keys = { { "", desc = "Open Test menu" } }, dependencies = { "nvim-lua/plenary.nvim", "nvim-treesitter/nvim-treesitter", @@ -18,11 +19,12 @@ return { require "neotest-go", require "neotest-rust", require "neotest-plenary", - require "neotest-vim-test" { - ignore_file_types = { "go", "lua", "rust", "php" }, - }, + -- require "neotest-vim-test" { + -- ignore_file_types = { "go", "lua", "rust", "php" }, + -- }, -- require("laravel.neotest"), }, + library = { plugins = { "neotest" }, types = true }, } local hydra = require "hydra" -- cgit v1.2.3