From 7701e1e3ebf73c58d2636a0707c08dca459a15ff Mon Sep 17 00:00:00 2001 From: Ariel D'Alessandro Date: Tue, 20 Sep 2022 17:45:11 +0200 Subject: disable hydra since was not working for the window as I was expecting --- after/plugin/hydra.lua | 44 ++++++++--------- after/plugin/lsp.lua | 13 ++--- after/plugin/null-ls.lua | 1 - lua/alpha/scratchs/draft.lua | 76 ------------------------------ lua/alpha/scratchs/graphql_queries.lua | 75 +++++++++++++++++++++++++++++ lua/alpha/scratchs/intelephense_symbol.lua | 28 +++++++++++ lua/alpha/snips/ft/php.lua | 3 ++ 7 files changed, 132 insertions(+), 108 deletions(-) delete mode 100644 lua/alpha/scratchs/draft.lua create mode 100644 lua/alpha/scratchs/graphql_queries.lua create mode 100644 lua/alpha/scratchs/intelephense_symbol.lua diff --git a/after/plugin/hydra.lua b/after/plugin/hydra.lua index 64088ab..2538f68 100644 --- a/after/plugin/hydra.lua +++ b/after/plugin/hydra.lua @@ -4,28 +4,28 @@ if not ok then end -- Windows management, move and resize -hydra({ - name = "windows", - mode = "n", - body = "", - heads = { - { "l", "l" }, - { "h", "h" }, - { "j", "j" }, - { "k", "k" }, - { "q", "q" }, - { "o", "o" }, - { "L", "2>" }, - { "H", "2<" }, - { "J", "2-" }, - { "K", "2+" }, - -- { "", "L" }, - -- { "", "H" }, - -- { "", "J" }, - -- { "", "K" }, - { "=", "=" }, - }, -}) +-- hydra({ +-- name = "windows", +-- mode = "n", +-- body = "", +-- heads = { +-- { "l", "l" }, +-- { "h", "h" }, +-- { "j", "j" }, +-- { "k", "k" }, +-- { "q", "q" }, +-- { "o", "o" }, +-- { "L", "2>" }, +-- { "H", "2<" }, +-- { "J", "2-" }, +-- { "K", "2+" }, +-- -- { "", "L" }, +-- -- { "", "H" }, +-- -- { "", "J" }, +-- -- { "", "K" }, +-- { "=", "=" }, +-- }, +-- }) -- want a way to run make commands -- Make commands runs good but the output is not good diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index 981346c..479e5c2 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -55,8 +55,8 @@ vim.keymap.set("n", "vf", function() return vim.lsp.buf.format({ async = true }) end, {}) -vim.keymap.set("n", "vn", vim.diagnostic.goto_next, { buffer = 0 }) -vim.keymap.set("n", "vp", vim.diagnostic.goto_prev, { buffer = 0 }) +vim.keymap.set("n", "vn", vim.diagnostic.goto_next, {}) +vim.keymap.set("n", "vp", vim.diagnostic.goto_prev, {}) local function on_attach(client, bufnr) local filetype = vim.api.nvim_buf_get_option(0, "filetype") @@ -81,13 +81,6 @@ local function on_attach(client, bufnr) filetype_attach[filetype](client,bufnr) end --- vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, { --- underline = true, --- update_in_insert = false, --- virtual_text = { spacing = 2, prefix = "●" }, --- severity_sort = true, --- }) - vim.diagnostic.config({ virtual_text = false, }) @@ -103,6 +96,8 @@ local lsp_flags = { debounce_text_changes = 150, } +-- Server configurations + require("lspconfig")["rust_analyzer"].setup({ on_attach = on_attach, flags = lsp_flags, diff --git a/after/plugin/null-ls.lua b/after/plugin/null-ls.lua index b530724..450f484 100644 --- a/after/plugin/null-ls.lua +++ b/after/plugin/null-ls.lua @@ -11,7 +11,6 @@ local sources = { -- null_ls.builtins.diagnostics.eslint, null_ls.builtins.diagnostics.phpstan.with({ command = "./bin/phpstan", - to_temp_file= false, }), null_ls.builtins.diagnostics.phpcs.with({ command = "./bin/phpcs", diff --git a/lua/alpha/scratchs/draft.lua b/lua/alpha/scratchs/draft.lua deleted file mode 100644 index 8954fdc..0000000 --- a/lua/alpha/scratchs/draft.lua +++ /dev/null @@ -1,76 +0,0 @@ -local pickers = require("telescope.pickers") -local finders = require("telescope.finders") -local conf = require("telescope.config").values -local action_state = require("telescope.actions.state") -local action_set = require("telescope.actions.set") -local get_node_text = vim.treesitter.get_node_text - -local function getElements() - vim.treesitter.set_query( - "yaml", - "GraphQL_endpoints", - [[ - (document (block_node (block_mapping (block_mapping_pair - value: (block_node (block_mapping (block_mapping_pair - value: (block_node (block_mapping (block_mapping_pair - value: (block_node (block_mapping (block_mapping_pair - key: (flow_node) @mutation - value: (block_node (block_mapping (block_mapping_pair - key: (flow_node) @resolve (#eq? @resolve "resolve") - value: (flow_node) @resolver - ))) - ))) - ))) - ))) - )))) - ]] - ) - - local query = vim.treesitter.get_query("yaml", "GraphQL_endpoints") - - local elements = {} - - local parsers = require("nvim-treesitter.parsers") - local parser = parsers.get_parser(0) - ---@diagnostic disable-next-line: deprecated - local tree = unpack(parser:parse()) - - for id, node in query:iter_captures(tree:root(), 0) do - if query.captures[id] == "mutation" then - table.insert(elements, { get_node_text(node, 0), node:start() + 1 }) - end - end - - return elements -end - -function Queries(opts) - opts = opts or {} - pickers.new(opts, { - promt_title = "Queries", - finder = finders.new_table({ - results = getElements(), - entry_maker = function(entry) - return { - value = entry, - display = entry[1], - ordinal = entry[1], - path = vim.api.nvim_buf_get_name(0), - lnum = entry[2], - } - end, - }), - sorter = conf.generic_sorter(opts), - previewer = conf.grep_previewer(opts), - attach_mappings = function() - action_set.select:enhance({ - post = function() - local selection = action_state.get_selected_entry() - vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 }) - end, - }) - - return true - end, - }):find() -end diff --git a/lua/alpha/scratchs/graphql_queries.lua b/lua/alpha/scratchs/graphql_queries.lua new file mode 100644 index 0000000..3997d86 --- /dev/null +++ b/lua/alpha/scratchs/graphql_queries.lua @@ -0,0 +1,75 @@ +local pickers = require("telescope.pickers") +local finders = require("telescope.finders") +local conf = require("telescope.config").values +local action_state = require("telescope.actions.state") +local action_set = require("telescope.actions.set") +local get_node_text = vim.treesitter.get_node_text + +local function getElements() + vim.treesitter.set_query( + "yaml", + "GraphQL_endpoints", + [[ + (document (block_node (block_mapping (block_mapping_pair + value: (block_node (block_mapping (block_mapping_pair + value: (block_node (block_mapping (block_mapping_pair + value: (block_node (block_mapping (block_mapping_pair + key: (flow_node) @mutation + value: (block_node (block_mapping (block_mapping_pair + key: (flow_node) @resolve (#eq? @resolve "resolve") + value: (flow_node) @resolver + ))) + ))) + ))) + ))) + )))) + ]] + ) + + local query = vim.treesitter.get_query("yaml", "GraphQL_endpoints") + + local elements = {} + + local parsers = require("nvim-treesitter.parsers") + local parser = parsers.get_parser(0) + local tree = unpack(parser:parse()) + + for id, node in query:iter_captures(tree:root(), 0) do + if query.captures[id] == "mutation" then + table.insert(elements, { get_node_text(node, 0), node:start() + 1 }) + end + end + + return elements +end + +function Queries(opts) + opts = opts or {} + pickers.new(opts, { + promt_title = "Queries", + finder = finders.new_table({ + results = getElements(), + entry_maker = function(entry) + return { + value = entry, + display = entry[1], + ordinal = entry[1], + path = vim.api.nvim_buf_get_name(0), + lnum = entry[2], + } + end, + }), + sorter = conf.generic_sorter(opts), + previewer = conf.grep_previewer(opts), + attach_mappings = function() + action_set.select:enhance({ + post = function() + local selection = action_state.get_selected_entry() + vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 }) + end, + }) + + return true + end, + }):find() +end diff --git a/lua/alpha/scratchs/intelephense_symbol.lua b/lua/alpha/scratchs/intelephense_symbol.lua new file mode 100644 index 0000000..3f039f3 --- /dev/null +++ b/lua/alpha/scratchs/intelephense_symbol.lua @@ -0,0 +1,28 @@ +local function get_intelephense_buffer() + local clients = vim.lsp.get_active_clients({ name = "intelephense" }) + if #clients == 0 then + return + end + + local intelephense = clients[1] + + local attached_buffers = intelephense.attached_buffers + + for key, val in pairs(attached_buffers) do + if val then + return key + end + end + + return nil +end + +vim.keymap.set({'n'}, 'pc', function () + local buffer = get_intelephense_buffer() + + if buffer == nil then + return + end + + require("telescope.builtin").lsp_workspace_symbols({ bufnr = buffer, query = vim.fn.expand("") }) +end) diff --git a/lua/alpha/snips/ft/php.lua b/lua/alpha/snips/ft/php.lua index 70cf49b..a9bbe37 100644 --- a/lua/alpha/snips/ft/php.lua +++ b/lua/alpha/snips/ft/php.lua @@ -48,6 +48,9 @@ local namespace = function() end end dir = dir:gsub("/", "\\") + if dir == "" then + return globalNamespace + end return string.format("%s\\%s", globalNamespace, dir) end -- cgit v1.2.3