From 17d5904b58871b2317f97e0cee0367dacbd9f4fc Mon Sep 17 00:00:00 2001 From: shelken Date: Thu, 18 Apr 2024 15:03:48 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20goto-preview?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lua/plugins/astrocore.lua | 12 ++++++++++ lua/plugins/goto-preview.lua | 5 +++++ lua/plugins/none-ls.lua | 43 +++++++++++++++++++++++++++++++----- 3 files changed, 54 insertions(+), 6 deletions(-) create mode 100644 lua/plugins/goto-preview.lua diff --git a/lua/plugins/astrocore.lua b/lua/plugins/astrocore.lua index 9c94b96..15d0b77 100644 --- a/lua/plugins/astrocore.lua +++ b/lua/plugins/astrocore.lua @@ -77,6 +77,18 @@ return { function() require("telescope").extensions.yank_history.yank_history() end, desc = "Preview Yank History", }, + -- implementation/definition preview + ["gpd"] = { "lua require('goto-preview').goto_preview_definition()", desc = "goto_preview_definition" }, + ["gpt"] = { + "lua require('goto-preview').goto_preview_type_definition()", + desc = "goto_preview_type_definition", + }, + ["gpi"] = { + "lua require('goto-preview').goto_preview_implementation()", + desc = "goto_preview_implementation", + }, + ["gP"] = { "lua require('goto-preview').close_all_win()", desc = "close_all_win" }, + ["gpr"] = { "lua require('goto-preview').goto_preview_references()", desc = "goto_preview_references" }, }, x = { diff --git a/lua/plugins/goto-preview.lua b/lua/plugins/goto-preview.lua new file mode 100644 index 0000000..6765c39 --- /dev/null +++ b/lua/plugins/goto-preview.lua @@ -0,0 +1,5 @@ +---@type LazySpec +return { + "rmagatti/goto-preview", + config = function() require("goto-preview").setup {} end, +} diff --git a/lua/plugins/none-ls.lua b/lua/plugins/none-ls.lua index 727603f..7c817dd 100644 --- a/lua/plugins/none-ls.lua +++ b/lua/plugins/none-ls.lua @@ -1,19 +1,50 @@ --- Customize None-ls sources - ---@type LazySpec return { "nvimtools/none-ls.nvim", opts = function(_, config) -- config variable is the default configuration table for the setup function call - -- local null_ls = require "null-ls" + local null_ls = require "null-ls" + local code_actions = null_ls.builtins.code_actions + local diagnostics = null_ls.builtins.diagnostics + local formatting = null_ls.builtins.formatting + local hover = null_ls.builtins.hover + local completion = null_ls.builtins.completion -- Check supported formatters and linters -- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/formatting -- https://github.com/nvimtools/none-ls.nvim/tree/main/lua/null-ls/builtins/diagnostics config.sources = { - -- Set a formatter - -- null_ls.builtins.formatting.stylua, - -- null_ls.builtins.formatting.prettier, + -- Common Code Actions + code_actions.gitsigns, + -- common refactoring actions based off the Refactoring book by Martin Fowler + code_actions.refactoring, + code_actions.gomodifytags, -- Go - modify struct field tags + code_actions.impl, -- Go - generate interface method stubs + code_actions.proselint, -- English prose linter + code_actions.statix, -- Lints and suggestions for Nix. + + -- Diagnostic + diagnostics.actionlint, -- GitHub Actions workflow syntax checking + diagnostics.buf, -- check text in current buffer + diagnostics.checkmake, -- check Makefiles + diagnostics.deadnix, -- Scan Nix files for dead code. + diagnostics.hadolint, -- Dockerfile linter + + -- Formatting + formatting.prettier, -- js/ts/vue/css/html/json/... formatter + formatting.black, -- Python formatter + formatting.goimports, -- Go formatter + formatting.shfmt, -- Shell formatter + formatting.terraform_fmt, -- Terraform formatter + formatting.stylua, -- Lua formatter + formatting.alejandra, -- Nix formatter + -- formatting.sqlfluff.with { -- SQL formatter + -- extra_args = { "--dialect", "postgres" }, -- change to your dialect + -- }, + formatting.nginx_beautifier, -- Nginx formatter + formatting.verible_verilog_format, -- Verilog formatter + -- formatting.emacs_scheme_mode, -- using emacs in batch mode to format scheme files. + -- formatting.fnlfmt, -- Format Fennel code } return config -- return final config table end,