aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAriel D'Alessandro <ariel.dalessandro@auto1.com>2022-06-17 17:39:56 +0200
committerAriel D'Alessandro <ariel.dalessandro@auto1.com>2022-06-17 17:39:56 +0200
commit09361db9ee52be27ddb27320eda8121223330f04 (patch)
tree186b2f6d6b2391739e150f49dcffe1891702bb9d
parent03436a47918c8c5229e435481cafdae61dd67fc5 (diff)
downloadnvim-conf-09361db9ee52be27ddb27320eda8121223330f04.tar.gz
nvim-conf-09361db9ee52be27ddb27320eda8121223330f04.zip
commits from laptop
-rw-r--r--after/plugin/feline.lua4
-rw-r--r--after/plugin/luasnip.lua1
-rw-r--r--after/plugin/null-ls.lua25
-rw-r--r--lua/alpha/php_code_actions.lua11
-rw-r--r--lua/alpha/plugins.lua16
-rw-r--r--lua/alpha/scratchs/draft.lua144
-rw-r--r--lua/alpha/snips/ft/yaml.lua90
-rw-r--r--plugin/keymaps.vim3
-rw-r--r--plugin/packer_compiled.lua28
9 files changed, 182 insertions, 140 deletions
diff --git a/after/plugin/feline.lua b/after/plugin/feline.lua
index d3a332a..d2de449 100644
--- a/after/plugin/feline.lua
+++ b/after/plugin/feline.lua
@@ -29,7 +29,7 @@ feline.winbar.setup({
provider = {
name = 'file_info',
opts = {
- type = 'full-path',
+ type = 'relative',
file_modified_icon = ''
},
},
@@ -46,7 +46,7 @@ feline.winbar.setup({
provider = {
name = 'file_info',
opts = {
- type = 'full-path',
+ type = 'relative',
file_modified_icon = ''
},
},
diff --git a/after/plugin/luasnip.lua b/after/plugin/luasnip.lua
index 9891eb3..8538b8e 100644
--- a/after/plugin/luasnip.lua
+++ b/after/plugin/luasnip.lua
@@ -95,6 +95,7 @@ local make = function(tbl)
return result
end
+ls.cleanup()
for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/alpha/snips/ft/*.lua", true)) do
local ft = vim.fn.fnamemodify(ft_path, ":t:r")
ls.add_snippets(ft, make(loadfile(ft_path)()))
diff --git a/after/plugin/null-ls.lua b/after/plugin/null-ls.lua
index 7d7d3b2..357a3d3 100644
--- a/after/plugin/null-ls.lua
+++ b/after/plugin/null-ls.lua
@@ -1,18 +1,27 @@
local ok, null_ls = pcall(require, "null-ls")
if not ok then
- return
+ return
end
+local my_sources = require("alpha.php_code_actions")
+
local sources = {
- null_ls.builtins.code_actions.gitsigns,
- null_ls.builtins.formatting.stylua,
- null_ls.builtins.diagnostics.eslint,
- null_ls.builtins.diagnostics.phpstan,
-}
+ null_ls.builtins.code_actions.gitsigns,
+ null_ls.builtins.formatting.stylua,
+ null_ls.builtins.diagnostics.eslint,
+ null_ls.builtins.diagnostics.phpstan,
+ null_ls.builtins.formatting.phpcsfixer,
+ null_ls.builtins.diagnostics.golangci_lint,
+ -- null_ls.builtins.formatting.goimports,
+ null_ls.builtins.formatting.jq,
+ null_ls.builtins.code_actions.gitrebase,
+ null_ls.builtins.code_actions.refactoring,
+ null_ls.builtins.completion.luasnip,
-require("alpha.php_code_actions")
+ my_sources.php_setter_getter_actions,
+}
null_ls.setup({
- sources = sources,
+ sources = sources,
})
diff --git a/lua/alpha/php_code_actions.lua b/lua/alpha/php_code_actions.lua
index f43245b..3d6b5e9 100644
--- a/lua/alpha/php_code_actions.lua
+++ b/lua/alpha/php_code_actions.lua
@@ -45,7 +45,9 @@ vim.treesitter.set_query(
]]
)
-local php_setter_getter_actions = {
+local M = {}
+
+M.php_setter_getter_actions = {
method = null_ls.methods.CODE_ACTION,
filetypes = { "php" },
generator = {
@@ -86,6 +88,7 @@ local php_setter_getter_actions = {
for _, match in comment_query:iter_matches(test_node, 0) do
for _, subNode in pairs(match) do
local type = get_node_text(subNode, 0)
+ P(type)
if type ~= "null" then
table.insert(property_types, type)
else
@@ -94,6 +97,7 @@ local php_setter_getter_actions = {
end
end
+ P(property_types)
local getter = generator.getGetter(property_name, nullable, property_types)
local setter = generator.getSetter(property_name, nullable, property_types)
@@ -126,6 +130,5 @@ local php_setter_getter_actions = {
end,
},
}
--- uncomment when not developing this
-null_ls.reset_sources()
-null_ls.register(php_setter_getter_actions)
+
+return M
diff --git a/lua/alpha/plugins.lua b/lua/alpha/plugins.lua
index a82dfca..b736e1b 100644
--- a/lua/alpha/plugins.lua
+++ b/lua/alpha/plugins.lua
@@ -95,10 +95,6 @@ return require("packer").startup(function(use)
"jose-elias-alvarez/null-ls.nvim",
})
- use("github/copilot.vim")
-
- use("kdheepak/lazygit.nvim")
-
use({
"nvim-telescope/telescope.nvim",
requires = {
@@ -127,10 +123,6 @@ return require("packer").startup(function(use)
end,
})
- -- use({
- -- "nvim-lualine/lualine.nvim",
- -- requires = { "kyazdani42/nvim-web-devicons", opt = true },
- -- })
use("feline-nvim/feline.nvim")
use({
@@ -143,13 +135,7 @@ return require("packer").startup(function(use)
},
})
- use({
- "noahfrederick/vim-laravel",
- requires = {
- { "tpope/vim-projectionist" },
- { "noahfrederick/vim-composer" },
- },
- })
+ use({ "noahfrederick/vim-composer" })
use({
"folke/trouble.nvim",
diff --git a/lua/alpha/scratchs/draft.lua b/lua/alpha/scratchs/draft.lua
index 32b9c8d..8954fdc 100644
--- a/lua/alpha/scratchs/draft.lua
+++ b/lua/alpha/scratchs/draft.lua
@@ -1,100 +1,76 @@
-local api = vim.api
-
-function GlobalFunction()
- local position_params = vim.lsp.util.make_position_params()
- P(position_params)
-
- vim.lsp.buf_request(0, "textDocument/completion", position_params, function(err, result)
- if vim.tbl_isempty(result or {}) then return end
-
- local textEdit = result.items[1].additionalTextEdits;
-
- local bufnr = vim.api.nvim_get_current_buf()
- vim.lsp.util.apply_text_edits(textEdit, bufnr)
- end)
-end
-
-local ts_locals = require "nvim-treesitter.locals"
-local ts_utils = require "nvim-treesitter.ts_utils"
-
+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 get_root_node()
- local node = ts_utils.get_node_at_cursor()
- if node == nil then
- error("No treesitter parser found.")
- end
-
- local parent = node:parent()
- while (parent ~= nil) do
- node = parent
- parent = node:parent()
- end
-
- return node
-end
-
--- this function allows me to retrieve all the queries or mutations
--- from the yaml file
--- next integrate with telescope to quick search
--- actions, go to the file line
--- new action open the php class on the method (lsp maybe, but the problem is not attached)
-function Queries()
+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) @name))
-))))))))))
- )
-)
+ (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 rootNode = get_root_node()
- for _, node in query:iter_captures(rootNode, 0, rootNode:start(), rootNode:end_()) do
- P(get_node_text(node, 0))
- P(node:start())
- P(node:end_())
+ 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
-end
-local function get_visual_selection()
- local s_start = vim.fn.getpos("'<")
- local s_end = vim.fn.getpos("'>")
- local n_lines = math.abs(s_end[2] - s_start[2]) + 1
- local lines = vim.api.nvim_buf_get_lines(0, s_start[2] - 1, s_end[2], false)
- lines[1] = string.sub(lines[1], s_start[3], -1)
- if n_lines == 1 then
- lines[n_lines] = string.sub(lines[n_lines], 1, s_end[3] - s_start[3] + 1)
- else
- lines[n_lines] = string.sub(lines[n_lines], 1, s_end[3])
- end
- return table.concat(lines, '\n')
+ return elements
end
-function GetPhpString()
- local s_start = vim.fn.getpos("'<")
- local s_end = vim.fn.getpos("'>")
- local text = get_visual_selection()
- P(text)
- local result = vim.fn.system("php -r 'echo \"" .. text .. "\";'")
- vim.api.nvim_put({result}, "", true, false)
- P(result)
- vim.api.nvim_buf_set_text(0, s_start[2] -1 , s_start[3] -1, s_end[2] -1, s_end[3], {result})
+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
-
-vim.keymap.set('n', '<leader>rrh', GetPhpString, {})
diff --git a/lua/alpha/snips/ft/yaml.lua b/lua/alpha/snips/ft/yaml.lua
new file mode 100644
index 0000000..708a67e
--- /dev/null
+++ b/lua/alpha/snips/ft/yaml.lua
@@ -0,0 +1,90 @@
+local ls = require("luasnip")
+
+local snippet_from_nodes = ls.sn
+local c = ls.choice_node
+local t = ls.text_node
+local d = ls.dynamic_node
+local f = ls.function_node
+local i = ls.insert_node
+local fmt = require("luasnip.extras.fmt").fmt
+
+local M = {
+ str = fmt([[{}:
+ type: string
+{}]], {
+ i(1, ""),
+ i(2, ""),
+ }),
+ bool = fmt([[{}:
+ type: boolean
+{}]], {
+ i(1, ""),
+ i(2, ""),
+ }),
+ float = fmt([[{}:
+ type: number
+ format: float
+{}]], {
+ i(1, ""),
+ i(2, "")
+ }),
+ int = fmt([[{}:
+ type: integer
+{}]], {
+ i(1, ""),
+ i(2, "")
+ }),
+ id = fmt([[{}:
+ type: integer
+ format: int64
+{}]], {
+ i(1, ""),
+ i(2, "")
+ }),
+ class = fmt([[{}:
+ $ref: '#/components/schemas/{}'
+{}]], {
+ i(1, ""),
+ i(2, ""),
+ i(3, "")
+ }),
+ date = fmt([[{}:
+ type: string
+ format: date-time
+{}]], {
+ i(1, ""),
+ i(2, "")
+ }),
+ arr = fmt([[{}:
+ type: array
+ items:
+ {}
+{}]], {
+ i(1, ""),
+ i(2, ""),
+ i(3, "")
+ }),
+ ref = fmt([[$ref: '#/components/schemas/{}']], {i(1, "")}),
+ obj = fmt([[type: object
+properties:
+ {}]], i(1, "")),
+ aint = fmt([[{}:
+ type: array
+ items:
+ type: int
+ format: int64
+{}]], {
+ i(1, ""),
+ i(2, ""),
+ }),
+ astr = fmt([[{}:
+ type: array
+ items:
+ type: string
+{}]], {
+ i(1, ""),
+ i(2, ""),
+ }),
+}
+
+return M
diff --git a/plugin/keymaps.vim b/plugin/keymaps.vim
index b19f243..34078f8 100644
--- a/plugin/keymaps.vim
+++ b/plugin/keymaps.vim
@@ -1,8 +1,5 @@
scriptencoding utf-8
-nnoremap * /\<<C-R>=expand('<cword>')<CR>\><CR>
-nnoremap # ?\<<C-R>=expand('<cword>')<CR>\><CR>
-
vnoremap <leader>p "_dP
nnoremap Y y$
diff --git a/plugin/packer_compiled.lua b/plugin/packer_compiled.lua
index c45dcd1..a3b2cfb 100644
--- a/plugin/packer_compiled.lua
+++ b/plugin/packer_compiled.lua
@@ -114,11 +114,6 @@ _G.packer_plugins = {
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/colorbuddy.nvim",
url = "https://github.com/tjdevries/colorbuddy.nvim"
},
- ["copilot.vim"] = {
- loaded = true,
- path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/copilot.vim",
- url = "https://github.com/github/copilot.vim"
- },
delimitMate = {
loaded = true,
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/delimitMate",
@@ -165,11 +160,6 @@ _G.packer_plugins = {
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/iron.nvim",
url = "https://github.com/hkupty/iron.nvim"
},
- ["lazygit.nvim"] = {
- loaded = true,
- path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/lazygit.nvim",
- url = "https://github.com/kdheepak/lazygit.nvim"
- },
["lspkind-nvim"] = {
loaded = true,
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/lspkind-nvim",
@@ -389,11 +379,6 @@ _G.packer_plugins = {
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/vim-fugitive",
url = "https://github.com/tpope/vim-fugitive"
},
- ["vim-laravel"] = {
- loaded = true,
- path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/vim-laravel",
- url = "https://github.com/noahfrederick/vim-laravel"
- },
["vim-maximizer"] = {
loaded = true,
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/vim-maximizer",
@@ -404,11 +389,6 @@ _G.packer_plugins = {
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/vim-obsession",
url = "https://github.com/tpope/vim-obsession"
},
- ["vim-projectionist"] = {
- loaded = true,
- path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/vim-projectionist",
- url = "https://github.com/tpope/vim-projectionist"
- },
["vim-repeat"] = {
loaded = true,
path = "/home/adalessa/.local/share/nvim/site/pack/packer/start/vim-repeat",
@@ -445,10 +425,6 @@ _G.packer_plugins = {
}
time([[Defining packer_plugins]], false)
--- Config for: nvim-colorizer.lua
-time([[Config for nvim-colorizer.lua]], true)
-try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\14colorizer\frequire\0", "config", "nvim-colorizer.lua")
-time([[Config for nvim-colorizer.lua]], false)
-- Config for: nvim-projectconfig
time([[Config for nvim-projectconfig]], true)
try_loadstring("\27LJ\2\n@\0\0\3\0\3\0\0066\0\0\0'\2\1\0B\0\2\0029\0\2\0B\0\1\1K\0\1\0\nsetup\23nvim-projectconfig\frequire\0", "config", "nvim-projectconfig")
@@ -457,6 +433,10 @@ time([[Config for nvim-projectconfig]], false)
time([[Config for git-worktree.nvim]], true)
try_loadstring("\27LJ\2\n>\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\17git-worktree\frequire\0", "config", "git-worktree.nvim")
time([[Config for git-worktree.nvim]], false)
+-- Config for: nvim-colorizer.lua
+time([[Config for nvim-colorizer.lua]], true)
+try_loadstring("\27LJ\2\n;\0\0\3\0\3\0\a6\0\0\0'\2\1\0B\0\2\0029\0\2\0004\2\0\0B\0\2\1K\0\1\0\nsetup\14colorizer\frequire\0", "config", "nvim-colorizer.lua")
+time([[Config for nvim-colorizer.lua]], false)
-- Command lazy-loads
time([[Defining lazy-load commands]], true)