diff options
Diffstat (limited to 'lua')
37 files changed, 513 insertions, 73 deletions
diff --git a/lua/alpha/animations.lua b/lua/alpha/animations.lua new file mode 100644 index 0000000..c0b7a6c --- /dev/null +++ b/lua/alpha/animations.lua @@ -0,0 +1,50 @@ +local redraw_buffer = function() + local Animation = require "animation" + local fps = 45 -- frames per second + local easing = require "animation.easing" + + local buffer = 0 + local len = 0 + local place_holder = {} + + local lines = vim.api.nvim_buf_get_lines(buffer, 0, -1, true) + + for _, line in ipairs(lines) do + len = len + string.len(line) + table.insert(place_holder, "") + end + + vim.api.nvim_buf_set_lines(buffer, 0, #lines, true, place_holder) + + local duration = math.ceil(len / fps * 1000) + + local i = 1 + local line_nr = 1 + local insertLine = "" + + local function callback() + if lines[line_nr] == nil then + return true + end + local char = string.sub(lines[line_nr], i, i) + if char == nil then + return true + end + insertLine = insertLine .. char + i = i + 1 + vim.api.nvim_buf_set_lines(buffer, line_nr - 1, line_nr, true, { insertLine }) + + if insertLine == lines[line_nr] then + i = 1 + line_nr = line_nr + 1 + insertLine = "" + end + end + + local animation = Animation(duration, fps, easing.line, callback) + animation:run() +end + +return { + redraw_buffer = redraw_buffer, +} diff --git a/lua/alpha/completition/init.lua b/lua/alpha/completition/init.lua index 02c9978..35ba27e 100644 --- a/lua/alpha/completition/init.lua +++ b/lua/alpha/completition/init.lua @@ -40,7 +40,7 @@ cmp.setup { { name = "nvim_lsp" }, { name = "path" }, { name = "luasnip" }, - { name = "nvim_lsp_signature_help" }, + { name = "copilot", group_index = 2 }, { name = "buffer", keyword_length = 4, @@ -49,7 +49,7 @@ cmp.setup { local bufs = {} for _, win in ipairs(vim.api.nvim_list_wins()) do local bufnr = vim.api.nvim_win_get_buf(win) - if vim.api.nvim_buf_get_option(bufnr, 'buftype') ~= 'terminal' then + if vim.api.nvim_buf_get_option(bufnr, "buftype") ~= "terminal" then bufs[bufnr] = true end end @@ -70,10 +70,11 @@ cmp.setup { with_text = true, menu = { buffer = "[buf]", - nvim_lsp = "[LSP]", + nvim_lsp = "[ ]", nvim_lua = "[api]", path = "[path]", luasnip = "[snip]", + copilot = "[ﮧ ]", ["vim-dadbod-completion"] = "[DB]", }, }, @@ -94,6 +95,8 @@ cmp.setup { }, } +vim.api.nvim_set_hl(0, "CmpItemKindCopilot", {fg ="#6CC644"}) + -- Set configuration for specific filetype. cmp.setup.filetype("gitcommit", { sources = cmp.config.sources({ diff --git a/lua/alpha/globals.lua b/lua/alpha/globals.lua index b575c0c..e445e72 100644 --- a/lua/alpha/globals.lua +++ b/lua/alpha/globals.lua @@ -13,11 +13,11 @@ dump = function(...) return unpack(args) end -RELOAD = function(...) +Reload = function(...) return require("plenary.reload").reload_module(...) end R = function(name) - RELOAD(name) + Reload(name) return require(name) end diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua index 45ce904..bf5b645 100644 --- a/lua/alpha/lsp/attach.lua +++ b/lua/alpha/lsp/attach.lua @@ -29,6 +29,10 @@ return function(client, bufnr) vim.bo.omnifunc = "v:lua.vim.lsp.omnifunc" + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint(bufnr, true) + end + -- Attach any filetype specific options to the client filetype_attach[filetype](client, bufnr) end diff --git a/lua/alpha/lsp/init.lua b/lua/alpha/lsp/init.lua index d280e53..03bd61d 100644 --- a/lua/alpha/lsp/init.lua +++ b/lua/alpha/lsp/init.lua @@ -1,14 +1,12 @@ -- LSP configuration --- install servers and tools -require "alpha.lsp.mason" - local lspconfig = require "lspconfig" local servers = require "alpha.lsp.servers" - for server, setup in pairs(servers) do lspconfig[server].setup(setup()) end +-- install servers and tools +require "alpha.lsp.mason" require "alpha.lsp.null-ls" diff --git a/lua/alpha/lsp/mason.lua b/lua/alpha/lsp/mason.lua index e164562..161a205 100644 --- a/lua/alpha/lsp/mason.lua +++ b/lua/alpha/lsp/mason.lua @@ -7,9 +7,8 @@ mason.setup() local mason_servers = {} --- TODO: can be improve checking the setup function to see if sets the cmd for server, _ in pairs(servers) do - local cmd = lspconfig[server].document_config.default_config.cmd[1] + local cmd = lspconfig[server].cmd[1] if vim.fn.executable(cmd) == 0 then table.insert(mason_servers, server) end @@ -21,5 +20,7 @@ mason_lspconfig.setup { -- filter the list for the ones not globally installed require("mason-tool-installer").setup { - ensure_installed = require "alpha.lsp.tools", + ensure_installed = vim.tbl_filter(function (tool) + return vim.fn.executable(tool) == 0 + end, require "alpha.lsp.tools"), } diff --git a/lua/alpha/lsp/null-ls.lua b/lua/alpha/lsp/null-ls.lua index be3d4e9..3428ec6 100644 --- a/lua/alpha/lsp/null-ls.lua +++ b/lua/alpha/lsp/null-ls.lua @@ -11,16 +11,18 @@ null_ls.setup { null_ls.builtins.diagnostics.luacheck, null_ls.builtins.formatting.stylua, + null_ls.builtins.diagnostics.yamllint, + -- 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 + -- 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, @@ -36,3 +38,16 @@ vim.keymap.set({ "n", "v" }, "<leader>vca", vim.lsp.buf.code_action, {desc = "LS vim.keymap.set("n", "<leader>vf", function() return vim.lsp.buf.format { async = true } end, {desc = "LSP (null ls) Format file"}) + +-- function to toogle and possible restart it +vim.api.nvim_create_user_command("NullLsToggle", function() + local sources = vim.tbl_map(function(el) + return el.name + end, null_ls.get_sources()) + vim.ui.select(sources, {}, function(selected) + if not selected then + return + end + null_ls.toggle(selected) + end) +end, {}) diff --git a/lua/alpha/lsp/servers.lua b/lua/alpha/lsp/servers.lua index f09f523..d2233a1 100644 --- a/lua/alpha/lsp/servers.lua +++ b/lua/alpha/lsp/servers.lua @@ -28,8 +28,28 @@ return { flags = lsp_flags, } end, - ["html"] = default, - ["jsonls"] = default, + ["html"] = function () + local config = { + on_attach = lsp_attach, + flags = lsp_flags, + } + if vim.fn.executable("html-languageserver") == 1 then + config.cmd = { "html-languageserver", "--stdio" } + end + + return config + end, + ["jsonls"] = function () + local config = { + on_attach = lsp_attach, + flags = lsp_flags, + } + if vim.fn.executable("json-languageserver") == 1 then + config.cmd = { "json-languageserver", "--stdio" } + end + + return config + end, ["lua_ls"] = function() return { on_attach = lsp_attach, @@ -51,7 +71,7 @@ return { }, hint = { enable = true, - } + }, }, }, } @@ -63,8 +83,14 @@ return { on_attach = lsp_attach, flags = lsp_flags, filetypes = { "php", "cucumber" }, + init_options = { + ["language_server_worse_reflection.inlay_hints.enable"] = true, + -- ["language_server_worse_reflection.inlay_hints.types"] = true, + -- ["language_server_worse_reflection.inlay_hints.params"] = true, + }, } end, + ["pyright"] = default, ["rust_analyzer"] = function() return { on_attach = lsp_attach, diff --git a/lua/alpha/lsp/tools.lua b/lua/alpha/lsp/tools.lua index 4eb40b3..7919521 100644 --- a/lua/alpha/lsp/tools.lua +++ b/lua/alpha/lsp/tools.lua @@ -1,6 +1,8 @@ return { + "codelldb", "go-debug-adapter", - "php-debug-adapter", "js-debug-adapter", - "codelldb", + "php-debug-adapter", + "phpcs", + "phpstan", } diff --git a/lua/alpha/php/servers.lua b/lua/alpha/php/servers.lua index ba3680c..9450152 100644 --- a/lua/alpha/php/servers.lua +++ b/lua/alpha/php/servers.lua @@ -30,8 +30,7 @@ local config = require("lspconfig").phpactor config.root_dir = vim.fn.getcwd() local client_id = vim.lsp.start(config) -local client = vim.lsp.get_client_by_id(client_id) -P(client) +vim.lsp.get_client_by_id(client_id) -- use client.request or request_sync -- look for the direct of the symbol return { diff --git a/lua/alpha/select_to_quickfix.lua b/lua/alpha/select_to_quickfix.lua new file mode 100644 index 0000000..ebd1561 --- /dev/null +++ b/lua/alpha/select_to_quickfix.lua @@ -0,0 +1,53 @@ +local api = vim.api + +local function create_quickfix_entry(selection) + local filename, linenumber = selection:match "([^:]+):(%d+)" + + return { + filename = vim.fn.getcwd() .. "/" .. filename, + lnum = tonumber(linenumber), + col = 1, + text = filename, + } +end + +local function add_selections_to_quickfix(selections) + local quickfix_list = {} + + for _, selection in ipairs(selections) do + local entry = create_quickfix_entry(selection) + table.insert(quickfix_list, entry) + end + + vim.fn.setqflist(quickfix_list, "r") +end + +local function get_selections() + local _, end_line, _, _ = unpack(vim.fn.getpos "'>") + local _, start_line, _, _ = unpack(vim.fn.getpos "'<") + local lines = api.nvim_buf_get_lines(0, start_line - 1, end_line, false) + + local selections = {} + for _, line in ipairs(lines) do + for selection in line:gmatch "%S+" do + table.insert(selections, selection) + end + end + + return selections +end + +local function select_to_quickfix() + local selections = get_selections() + + if #selections > 0 then + add_selections_to_quickfix(selections) + print "Selections added to quickfix list" + else + print "No selections found" + end +end + +return { + handle = select_to_quickfix, +} diff --git a/lua/alpha/snips/ft/cucumber.lua b/lua/alpha/snips/ft/cucumber.lua index cb74586..6176a87 100644 --- a/lua/alpha/snips/ft/cucumber.lua +++ b/lua/alpha/snips/ft/cucumber.lua @@ -9,6 +9,13 @@ local M = { all = t [[And all stubs should be matched]], status_code = fmt([[Then the response status code should be {}]], { i(1, "200") }), no_error = t [[And the JSON path expression errors should not have result]], + json_data = fmt([[And the JSON path expression "data" should be equal to: +""" +{{ + {} +}} +""" + ]], {i(1)}), feature = fmt( [[Feature: {} diff --git a/lua/alpha/telescope/init.lua b/lua/alpha/telescope/init.lua index 38cd9be..c278028 100644 --- a/lua/alpha/telescope/init.lua +++ b/lua/alpha/telescope/init.lua @@ -1,16 +1,16 @@ -SHOULD_RELOAD_TELESCOPE = true +local SHOULD_RELOAD_TELESCOPE = true local reloader = function() if SHOULD_RELOAD_TELESCOPE then - RELOAD "plenary" - RELOAD "telescope" - RELOAD "alpha.telescope.setup" + Reload "plenary" + Reload "telescope" + Reload "alpha.telescope.setup" end end local fb_actions = require("telescope").extensions.file_browser.actions local actions = require "telescope.actions" -local my_actions = require "alpha.telescope.actions" +local my_actions = require "alpha.telescope.my_actions" local M = {} @@ -52,8 +52,8 @@ M.find_nvim_plugin = function() prompt_title = "< Plugins >", cwd = "$HOME/.config/nvim/lua/plugins/", attach_mappings = function(_, map) - map("i", "<C-t>", my_actions.create_plugin) - map("i", "<C-d>", my_actions.disable_plugin) + map("i", "<C-y>", my_actions.create_plugin) + map("i", "<C-w>", my_actions.disable_plugin) map("i", "<C-e>", my_actions.enable_plugin) return true diff --git a/lua/alpha/telescope/actions.lua b/lua/alpha/telescope/my_actions.lua index b0e9f10..b0e9f10 100644 --- a/lua/alpha/telescope/actions.lua +++ b/lua/alpha/telescope/my_actions.lua diff --git a/lua/alpha/telescope/setup.lua b/lua/alpha/telescope/setup.lua index cd5ad63..0e368c7 100644 --- a/lua/alpha/telescope/setup.lua +++ b/lua/alpha/telescope/setup.lua @@ -11,8 +11,57 @@ local set_prompt_to_entry_value = function(prompt_bufnr) action_state.get_current_picker(prompt_bufnr):reset_prompt(entry.ordinal) end +local filetype_hook = function(filepath, bufnr, opts) + -- Here for example you can say: if ft == "xyz" then this_regex_highlighing else nothing end + -- + local is_image = function(filepath) + local image_extensions = { "png", "jpg" } -- Supported image formats + local split_path = vim.split(filepath:lower(), ".", { plain = true }) + local extension = split_path[#split_path] + return vim.tbl_contains(image_extensions, extension) + end + if not is_image(filepath) then + return true + end + local ui = require "image.ui" + local options = require "image.options" + local dimensions = require "image.dimensions" + local api = require "image.api" + local config = require "image.config" + local user_opts = { + render = { + foreground_color = true, + background_color = true, + }, + } + local global_opts = vim.tbl_deep_extend("force", config.DEFAULT_OPTS, user_opts) + + local ascii_width, ascii_height, horizontal_padding, vertical_padding, img_width, img_height = + dimensions.calculate_ascii_width_height(opts.winid, filepath, global_opts) + options.set_options_before_render(bufnr) + ui.buf_clear(bufnr) + local label = ui.create_label( + filepath, + ascii_width, + horizontal_padding, + global_opts.render.show_image_dimensions, + img_width, + img_height + ) + + api.get_ascii_data_sync(filepath, ascii_width, ascii_height, global_opts, function(ascii_data) + ui.buf_insert_data_with_padding(bufnr, ascii_data, horizontal_padding, vertical_padding, label, global_opts) + + options.set_options_after_render(bufnr) + end) + return false +end + require("telescope").setup { defaults = { + preview = { + filetype_hook = filetype_hook, + }, prompt_prefix = "❯ ", selection_caret = "❯ ", @@ -30,7 +79,7 @@ require("telescope").setup { if cols > 200 then return math.floor(cols * 0.5) else - return math.floor(cols * 0.6) + return math.floor(cols * 0.7) end end, }, @@ -100,6 +149,7 @@ require("telescope").setup { path = "~/.local/share/nvim/databases/telescope_history.sqlite3", limit = 100, }, + -- buffer_previewer_maker = new_maker, }, pickers = { diff --git a/lua/config/autocmds.lua b/lua/config/autocmds.lua index b8953ce..c178f44 100644 --- a/lua/config/autocmds.lua +++ b/lua/config/autocmds.lua @@ -25,7 +25,7 @@ vim.api.nvim_create_autocmd("FileType", { }) vim.api.nvim_create_autocmd("FileType", { - pattern = { "gitcommit", "markdown", "NeogitCommitMessage" }, + pattern = { "gitcommit", "markdown", "NeogitCommitMessage", "norg" }, callback = function() vim.opt_local.wrap = true vim.opt_local.spell = true diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index f5c0248..22b786d 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,14 +1,27 @@ local map = vim.keymap.set map("v", "<leader>p", function() - local val = vim.fn.getreg '"' + local val = vim.fn.getreg '+' vim.api.nvim_command [[normal! p]] - vim.fn.setreg('"', val) + vim.fn.setreg('+', val) end, { desc = "Special paste, paste without replacing copy register content" }) +map("n", "<leader>mm", function() + local items = + vim.fn.systemlist "make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\\/\t=]*:([^=]|$)/ {split($1,A,/ /);print A[1]}'" + + vim.ui.select(items, { promt = "Make command" }, function(choice) + if not choice then + return + end + + require("harpoon.term").sendCommand(1, "make " .. choice) + end) +end) + map("n", "<leader>bd", ":bd!<CR>", { desc = "Deletes the current buffer" }) -map("n", "<leader>fz", function () +map("n", "<leader>fz", function() vim.cmd [[normal zfaf]] end, { desc = "Fold the function" }) @@ -56,3 +69,5 @@ map( map("n", "<leader>vn", vim.diagnostic.goto_next, { desc = "Goes to next diagnostic error" }) map("n", "<leader>vp", vim.diagnostic.goto_prev, { desc = "Goes to prev diagnostic error" }) + +map("v", "<leader>q", require('alpha.select_to_quickfix').handle) diff --git a/lua/config/options.lua b/lua/config/options.lua index 30a3127..7cbc205 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -3,7 +3,7 @@ vim.g.snippets = "luasnip" local opt = vim.o -opt.mouse = false +opt.mouse = "" opt.number = true opt.relativenumber = true opt.conceallevel = 3 @@ -37,8 +37,5 @@ opt.cmdheight = 1 opt.updatetime = 50 opt.signcolumn = "yes" opt.equalalways = false - -if vim.fn.has "nvim-0.9.0" == 1 then - opt.splitkeep = "screen" - opt.shortmess = "filnxtToOFWIcC" -end +opt.splitkeep = "screen" +opt.shortmess = "filnxtToOFWIcC" diff --git a/lua/plugins/animation.lua b/lua/plugins/animation.lua new file mode 100644 index 0000000..26cf364 --- /dev/null +++ b/lua/plugins/animation.lua @@ -0,0 +1,11 @@ +return { + "anuvyklack/animation.nvim", + dependencies = { + "anuvyklack/middleclass", + }, + keys = { + {"<leader>aa", function () + require("alpha.animations").redraw_buffer() + end} + }, +} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index a073169..bb80061 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -1,9 +1,18 @@ +-- return { +-- "wuelnerdotexe/vim-enfocado", +-- lazy = false, +-- priority = 1000, +-- config = function() +-- vim.cmd.colorscheme "enfocado" +-- end, +-- } return { - "catppuccin/nvim", - name = "catppuccin", - lazy = false, - priority = 1000, + "projekt0n/github-nvim-theme", + lazy = false, -- make sure we load this during startup if it is your main colorscheme + priority = 1000, -- make sure to load this before all the other start plugins config = function() - vim.cmd.colorscheme "catppuccin-mocha" + require("github-theme").setup {} + + vim.cmd.colorscheme "github_dark_tritanopia" end, } diff --git a/lua/plugins/completition.lua b/lua/plugins/completition.lua index 41abc02..795b016 100644 --- a/lua/plugins/completition.lua +++ b/lua/plugins/completition.lua @@ -11,7 +11,19 @@ return { "onsails/lspkind-nvim", { "L3MON4D3/LuaSnip", version = "v1.*" }, "windwp/nvim-autopairs", - "hrsh7th/cmp-nvim-lsp-signature-help", + { + "zbirenbaum/copilot-cmp", + dependencies = { + "zbirenbaum/copilot.lua", + cmd = { "Copilot" }, + event = { "VeryLazy" }, + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + }, + }, + config = true, + }, }, event = "VeryLazy", config = function() diff --git a/lua/plugins/image.lua b/lua/plugins/image.lua new file mode 100644 index 0000000..c8e231f --- /dev/null +++ b/lua/plugins/image.lua @@ -0,0 +1,12 @@ +return { + "samodostal/image.nvim", + dependencies = { + "m00qek/baleia.nvim", + }, + opts = { + render = { + foreground_color = true, + background_color = true, + } + }, +} diff --git a/lua/plugins/laravel.lua b/lua/plugins/laravel.lua index 3f689f6..0252bc0 100644 --- a/lua/plugins/laravel.lua +++ b/lua/plugins/laravel.lua @@ -3,15 +3,16 @@ return { dependencies = { "rcarriga/nvim-notify", "nvim-telescope/telescope.nvim", + "MunifTanjim/nui.nvim", }, - cmd = { "Sail", "Artisan", "Composer", "Npm", "Laravel" }, + cmd = { "Sail", "Artisan", "Composer", "Npm", "Laravel", "LaravelInfo" }, keys = { { "<leader>la", ":Laravel artisan<cr>", desc = "Laravel Application Commands" }, { "<leader>lr", ":Laravel routes<cr>", desc = "Laravel Application Routes" }, { "<leader>lt", function() - require("laravel").app.sendToTinker() + require("laravel.tinker").send_to_tinker() end, mode = "v", desc = "Laravel Application Routes", @@ -19,7 +20,11 @@ return { }, config = function() vim.g.laravel_log_level = "debug" - require("laravel").setup() + require("laravel").setup({ + route_info = { + position = "top", + } + }) require("telescope").load_extension "laravel" end, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 6bf565e..0458b7f 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -19,6 +19,7 @@ return { "WhoIsSethDaniel/mason-tool-installer.nvim", { "lvimuser/lsp-inlayhints.nvim", + enabled = false, config = function() require("lsp-inlayhints").setup() vim.api.nvim_create_augroup("LspAttach_inlayhints", {}) @@ -38,6 +39,7 @@ return { }, { "j-hui/fidget.nvim", + enabled = false, opts = { window = { blend = 0, diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 2a21c19..6594567 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -4,7 +4,7 @@ return { config = function() require("lualine").setup { options = { - theme = "catppuccin", + theme = "auto", icons_enabled = true, globalstatus = true, }, @@ -17,6 +17,11 @@ return { "diagnostics", "diff", { + require("noice").api.statusline.mode.get, + cond = require("noice").api.statusline.mode.has, + color = { fg = "#ff9e64" }, + }, + { require("lazy.status").updates, cond = require("lazy.status").has_updates, color = { fg = "ff9e64" }, diff --git a/lua/plugins/neodev.lua b/lua/plugins/neodev.lua new file mode 100644 index 0000000..1bb0cd1 --- /dev/null +++ b/lua/plugins/neodev.lua @@ -0,0 +1,4 @@ +return { + "folke/neodev.nvim", + opts = {} +} diff --git a/lua/plugins/neorg.lua b/lua/plugins/neorg.lua new file mode 100644 index 0000000..9273453 --- /dev/null +++ b/lua/plugins/neorg.lua @@ -0,0 +1,21 @@ +return { + "nvim-neorg/neorg", + build = ":Neorg sync-parser |