fix: telescope extensions, astrocore & astrolsp

This commit is contained in:
Ryan Yin
2024-04-13 21:59:57 +08:00
parent a1d827a34e
commit fb6ca6b12d
11 changed files with 65 additions and 95 deletions

View File

@@ -263,11 +263,11 @@ path:
$env.PATH | split row ":"
nvim-test:
rm -rf $"($env.HOME)/.config/astronvim/lua/user"
rsync -avz --copy-links --chmod=D2755,F744 home/base/desktop/editors/neovim/astronvim_user/ $"($env.HOME)/.config/astronvim/lua/user"
rm -rf $"($env.HOME)/.config/nvim"
rsync -avz --copy-links --chmod=D2755,F744 home/base/tui/editors/neovim/nvim/ $"($env.HOME)/.config/nvim/"
nvim-clean:
rm -rf $"($env.HOME)/.config/astronvim/lua/user"
rm -rf $"($env.HOME)/.config/nvim"
# =================================================
# Emacs related commands
@@ -289,7 +289,7 @@ reload-emacs-cmd := if os() == "macos" {
emacs-test:
rm -rf $"($env.HOME)/.config/doom"
rsync -avz --copy-links --chmod=D2755,F744 home/base/desktop/editors/emacs/doom/ $"($env.HOME)/.config/doom"
rsync -avz --copy-links --chmod=D2755,F744 home/base/tui/editors/emacs/doom/ $"($env.HOME)/.config/doom/"
doom clean
doom sync

View File

@@ -1,5 +1,3 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- AstroCommunity: import any community modules here
-- We import this file in `lazy_setup.lua` before the `plugins/` folder.
-- This guarantees that the specs are processed before any user plugins.

View File

@@ -1,14 +1,8 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- AstroCore provides a central place to modify mappings, vim options, autocommands, and more!
-- Configuration documentation can be found with `:h astrocore`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
require("telescope").load_extension "refactoring"
require("telescope").load_extension "yank_history"
require("telescope").load_extension "undo"
---@type LazySpec
return {
"AstroNvim/astrocore",
@@ -48,34 +42,18 @@ return {
},
},
-- Mappings can be configured through AstroCore as well.
-- https://docs.astronvim.com/recipes/mappings/
-- NOTE: keycodes follow the casing in the vimdocs. For example, `<Leader>` must be capitalized
mappings = {
-- first key is the mode
n = {
-- second key is the lefthand side of the map
-- navigate buffer tabs with `H` and `L`
L = { function() require("astrocore.buffer").nav(vim.v.count1) end, desc = "Next buffer" },
H = { function() require("astrocore.buffer").nav(-vim.v.count1) end, desc = "Previous buffer" },
-- mappings seen under group name "Buffer"
["<Leader>bD"] = {
function()
require("astroui.status.heirline").buffer_picker(
function(bufnr) require("astrocore.buffer").close(bufnr) end
)
end,
desc = "Pick to close",
},
-- tables with just a `desc` key will be registered with which-key if it's installed
-- this is useful for naming menus
["<Leader>b"] = { desc = "Buffers" },
-- second key is the lefthand side of the map
-- mappings seen under group name "Buffer"
["<Leader>bn"] = { "<cmd>tabnew<cr>", desc = "New tab" },
-- quick save
["<C-s>"] = { ":w!<cr>", desc = "Save File" }, -- change description but the same command
-- ["<C-s>"] = { ":w!<cr>", desc = "Save File" },
-- Terminal
-- NOTE: https://neovim.io/doc/user/builtin.html#jobstart()
@@ -92,33 +70,6 @@ return {
desc = "Search on current file",
},
-- refactoring
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inverse of extract variable",
},
["<Leader>rb"] = { function() require("refactoring").refactor "Extract Block" end, desc = "Extract Block" },
["<Leader>rbf"] = {
function() require("refactoring").refactor "Extract Block To File" end,
desc = "Extract Block To File",
},
["<Leader>rr"] = {
function() require("telescope").extensions.refactoring.refactors() end,
desc = "Prompt for a refactor to apply",
},
["<Leader>rp"] = {
function() require("refactoring").debug.printf { below = false } end,
desc = "Insert print statement to mark the calling of a function",
},
["<Leader>rv"] = {
function() require("refactoring").debug.print_var() end,
desc = "Insert print statement to print a variable",
},
["<Leader>rc"] = {
function() require("refactoring").debug.cleanup {} end,
desc = "Cleanup of all generated print statements",
},
-- yank_history
["<Leader>yh"] = {
function() require("telescope").extensions.yank_history.yank_history() end,
@@ -150,30 +101,7 @@ return {
-- search and replace globally
["<Leader>sw"] = { '<esc><cmd>lua require("spectre").open_visual()<CR>', desc = "Search current word" },
},
-- visual mode(what's the difference between v and x???)
x = {
-- refactoring
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inverse of extract variable",
},
["<Leader>re"] = {
function() require("refactoring").refactor "Extract Function" end,
desc = "Extracts the selected code to a separate function",
},
["<Leader>rf"] = {
function() require("refactoring").refactor "Extract Function To File" end,
desc = "Extract Function To File",
},
["<Leader>rv"] = {
function() require("refactoring").refactor "Extract Variable" end,
desc = "Extracts occurrences of a selected expression to its own variable",
},
["<Leader>rr"] = {
function() require("telescope").extensions.refactoring.refactors() end,
desc = "Prompt for a refactor to apply",
},
},
},
},
}

View File

@@ -1,10 +1,9 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- AstroLSP allows you to customize the features in AstroNvim's LSP configuration engine
-- Configuration documentation can be found with `:h astrolsp`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)
-- as this provides autocomplete and documentation while editing
---@type LazySpec
return {
"AstroNvim/astrolsp",
@@ -131,6 +130,7 @@ return {
mappings = {
n = {
gl = { function() vim.diagnostic.open_float() end, desc = "Hover diagnostics" },
-- a `cond` key can provided as the string of a server capability to be required to attach, or a function with `client` and `bufnr` parameters from the `on_attach` that returns a boolean
-- gD = {
-- function() vim.lsp.buf.declaration() end,
@@ -142,6 +142,57 @@ return {
-- desc = "Toggle LSP semantic highlight (buffer)",
-- cond = function(client) return client.server_capabilities.semanticTokensProvider and vim.lsp.semantic_tokens end,
-- },
-- refactoring
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inverse of extract variable",
},
["<Leader>rb"] = { function() require("refactoring").refactor "Extract Block" end, desc = "Extract Block" },
["<Leader>rbf"] = {
function() require("refactoring").refactor "Extract Block To File" end,
desc = "Extract Block To File",
},
["<Leader>rr"] = {
function() require("telescope").extensions.refactoring.refactors() end,
desc = "Prompt for a refactor to apply",
},
["<Leader>rp"] = {
function() require("refactoring").debug.printf { below = false } end,
desc = "Insert print statement to mark the calling of a function",
},
["<Leader>rv"] = {
function() require("refactoring").debug.print_var() end,
desc = "Insert print statement to print a variable",
},
["<Leader>rc"] = {
function() require("refactoring").debug.cleanup {} end,
desc = "Cleanup of all generated print statements",
},
},
-- visual mode(what's the difference between v and x???)
x = {
-- refactoring
["<Leader>ri"] = {
function() require("refactoring").refactor "Inline Variable" end,
desc = "Inverse of extract variable",
},
["<Leader>re"] = {
function() require("refactoring").refactor "Extract Function" end,
desc = "Extracts the selected code to a separate function",
},
["<Leader>rf"] = {
function() require("refactoring").refactor "Extract Function To File" end,
desc = "Extract Function To File",
},
["<Leader>rv"] = {
function() require("refactoring").refactor "Extract Variable" end,
desc = "Extracts occurrences of a selected expression to its own variable",
},
["<Leader>rr"] = {
function() require("telescope").extensions.refactoring.refactors() end,
desc = "Prompt for a refactor to apply",
},
},
},
-- A custom `on_attach` function to be run after the default `on_attach` function

View File

@@ -1,5 +1,3 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- AstroUI provides the basis for configuring the AstroNvim User Interface
-- Configuration documentation can be found with `:h astroui`
-- NOTE: We highly recommend setting up the Lua Language Server (`:LspInstall lua_ls`)

View File

@@ -1,5 +1,3 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- Customize Mason plugins
---@type LazySpec

View File

@@ -1,5 +1,3 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- Customize None-ls sources
---@type LazySpec

View File

@@ -33,6 +33,11 @@ return {
previewers.buffer_previewer_maker(filepath, bufnr, opts)
end
end)
-- Load Extensions
require("telescope").load_extension "refactoring"
require("telescope").load_extension "yank_history"
require("telescope").load_extension "undo"
end
require("telescope").setup {

View File

@@ -1,5 +1,3 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- Customize Treesitter
---@type LazySpec

View File

@@ -1,5 +1,3 @@
if true then return {} end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- You can also add or configure plugins by creating files in this `plugins/` folder
-- Here are some examples:

View File

@@ -1,5 +1,3 @@
if true then return end -- WARN: REMOVE THIS LINE TO ACTIVATE THIS FILE
-- This will run last in the setup process and is a good place to configure
-- things like custom filetypes. This just pure lua so anything that doesn't
-- fit in the normal config locations above can go here