Change telescope to dropdown, telescope now uses select_drow action, remove the hide telescope borders in tokyonight, change visible dirs and tokens in lspsaga lualine status, clangd header/source toggle now also uses drop over edit

This commit is contained in:
Martin Larsson 2024-01-29 01:44:58 +01:00
parent 8eecbb115e
commit 611c361951
6 changed files with 206 additions and 45 deletions

View file

@ -1 +1,43 @@
return {} local function switch_between_header_and_source(bufnr)
local util = require("lspconfig/util")
bufnr = util.validate_bufnr(bufnr)
local clangd_client = util.get_active_client_by_name(bufnr, "clangd")
local params = { uri = vim.uri_from_bufnr(bufnr) }
-- invert this with an early return
if not clangd_client then
print "method textDocument/switchSourceHeader is not supported by any servers active on the current buffer"
return
end
clangd_client.request("textDocument/switchSourceHeader", params, function(err, result)
if err then
error(tostring(err))
end
if not result then
print("Corresponding file cannot be determined")
return
end
vim.api.nvim_command("drop " .. vim.uri_to_fname(result))
end, bufnr)
end
local M = {
commands = {
ClangdSwitchSourceHeader = {
function()
switch_between_header_and_source(0)
end,
description = "Switch between source/header",
},
},
}
function M.post_setup()
require("utils").add_keymaps({
n = {
["<leader>ko"] = { cmd = ":ClangdSwitchSourceHeader<CR>" }
},
})
end
return M

View file

@ -1 +1,3 @@
return {} return {
}

View file

@ -13,11 +13,11 @@ return {
hide_keyword = true, hide_keyword = true,
ignore_patterns = nil, ignore_patterns = nil,
show_file = true, show_file = true,
folder_level = 3, folder_level = 2,
color_mode = true, color_mode = true,
dely = 300, dely = 300,
show_nodes = true, show_nodes = true,
max_nodes = 3, max_nodes = 2,
}, },
implement = { implement = {
enable = false, enable = false,

View file

@ -22,8 +22,8 @@ return {
-- Create a new table which contains the non-lsp setups for Mason (linters, formatters, etc) -- Create a new table which contains the non-lsp setups for Mason (linters, formatters, etc)
local mason_installs = vim.list_extend({ local mason_installs = vim.list_extend({
"clang-format", "clang-format",
--"cmakelang", "cmakelang",
--"luaformater", -- "luaformater",
}, server_names) }, server_names)
require("mason").setup() require("mason").setup()
@ -38,7 +38,13 @@ return {
for _, server_name in ipairs(server_names) do for _, server_name in ipairs(server_names) do
local server = lspconfig[server_name] local server = lspconfig[server_name]
if server then if server then
server.setup(require("language_servers/" .. server_name)) local server_table = require("language_servers/" .. server_name)
server.setup(server_table)
-- Run the post_setup function if it exists
if server_table.post_setup then
server_table.post_setup()
end
else else
error("LSP server not found: " .. server_name) error("LSP server not found: " .. server_name)
end end

View file

@ -5,37 +5,148 @@ return {
"nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-fzf-native.nvim",
}, },
config = function() config = function()
require("telescope").setup({ }) local actions = require("telescope.actions")
require("telescope").setup({
pickers = {
buffers = {
mappings = {
i = {
["<CR>"] = actions.select_drop,
},
n = {
["<CR>"] = actions.select_drop,
}
}
},
find_files = {
mappings = {
i = {
["<CR>"] = actions.select_drop,
},
n = {
["<CR>"] = actions.select_drop,
}
}
},
git_files = {
mappings = {
i = {
["<CR>"] = actions.select_drop,
},
n = {
["<CR>"] = actions.select_drop,
}
}
},
old_files = {
mappings = {
i = {
["<CR>"] = actions.select_drop,
},
n = {
["<CR>"] = actions.select_drop,
}
}
},
}
})
require("telescope").load_extension("fzf") require("telescope").load_extension("fzf")
local dropdown_theme = require('telescope.themes').get_dropdown({
-- results_height = 50,
width = 0.2,
winblend = 20,
prompt_title = "",
borderchars = {
{ '', '', '', '', '', '', '', ''},
prompt = {"", "", " ", "", '', '', "", ""},
results = {"", "", "", "", "", "", "", ""},
preview = { '', '', '', '', '', '', '', ''},
}
})
require("utils").add_keymaps({ require("utils").add_keymaps({
n = { n = {
-- File search -- File search
["<leader>to"] = { ["<leader>to"] = {
cmd = ":Telescope find_files <CR>", cmd = function()
dropdown_theme.prompt_prefix = "Files>"
dropdown_theme.previewer = false
dropdown_theme.find_command = nil
require("telescope.builtin").find_files(dropdown_theme)
end,
}, },
["<leader>tf"] = { ["<leader>tf"] = {
cmd = ":Telescope current_buffer_fuzzy_find<CR>", cmd = function()
dropdown_theme.prompt_prefix = "Find>"
dropdown_theme.previewer = true
dropdown_theme.find_command = nil
require("telescope.builtin").current_buffer_fuzzy_find(dropdown_theme)
end,
}, },
["<leader>ta"] = { ["<leader>ta"] = {
cmd = ":Telescope live_grep find_command=rg,--ignore-file,.gitignore,--exclude,*.git,--exclude,*.svn,--exclude,*.vs,--exclude,*.idea<CR>", -- cmd = ":lua require('telescope.builtin').live_grep({find_command=rg,--ignore-file,.gitignore,--exclude,*.git,--exclude,*.svn,--exclude,*.vs,--exclude,*.idea}) <CR>",
cmd = function()
dropdown_theme.prompt_prefix = "Grep>"
dropdown_theme.previewer = true
dropdown_theme.find_command = {
find_command = "rg",
"--ignore-file",
".gitignore",
"--exclude",
"*.git",
"--exclude",
"*.svn",
"--exclude",
"*.vs",
"--exclude",
"*.idea",
}
require("telescope.builtin").live_grep(dropdown_theme)
end,
}, },
-- Git -- Git
["<leader>gc"] = { ["<leader>gl"] = {
cmd = "<cmd> Telescope git_commits <CR>", cmd = function()
dropdown_theme.prompt_prefix = "Log>"
dropdown_theme.previewer = true
dropdown_theme.find_command = nil
require("telescope.builtin").git_commits(dropdown_theme)
end,
}, },
["<leader>gs"] = { ["<leader>gs"] = {
cmd = "<cmd> Telescope git_status <CR>", cmd = function()
dropdown_theme.prompt_prefix = "Status>"
dropdown_theme.previewer = true
dropdown_theme.find_command = nil
require("telescope.builtin").git_status(dropdown_theme)
end,
}, },
["<leader>gh"] = { ["<leader>gh"] = {
cmd = "<cmd> Telescope git_bcommits <CR>", cmd = function()
dropdown_theme.prompt_prefix = "History>"
dropdown_theme.previewer = true
dropdown_theme.find_command = nil
require("telescope.builtin").git_bcommits(dropdown_theme)
end,
}, },
["<leader>gb"] = { ["<leader>gb"] = {
cmd = "<cmd> Telescope git_branches <CR>", cmd = function()
dropdown_theme.prompt_prefix = "Branches>"
dropdown_theme.previewer = true
dropdown_theme.find_command = nil
require("telescope.builtin").git_branches(dropdown_theme)
end,
}, },
-- Misc -- Misc
["<leader>tb"] = { ["<leader>tb"] = {
cmd = "<cmd> Telescope marks <CR>", cmd = function()
dropdown_theme.prompt_prefix = "Marks>"
dropdown_theme.previewer = true
dropdown_theme.find_command = nil
require("telescope.builtin").marks(dropdown_theme)
end,
} }
} }
}) })

View file

@ -32,34 +32,34 @@ return {
---@param highlights Highlights ---@param highlights Highlights
---@param colors ColorScheme ---@param colors ColorScheme
on_highlights = function(highlights, colors) on_highlights = function(highlights, colors)
local prompt = "#2d3149" -- local prompt = "#2d3149"
highlights.TelescopeNormal = { -- highlights.TelescopeNormal = {
bg = colors.bg_dark, -- bg = colors.bg_dark,
fg = colors.fg_dark, -- fg = colors.fg_dark,
} -- }
highlights.TelescopeBorder = { -- highlights.TelescopeBorder = {
bg = colors.bg_dark, -- bg = colors.bg_dark,
fg = colors.bg_dark, -- fg = colors.bg_dark,
} -- }
highlights.TelescopePromptNormal = { -- highlights.TelescopePromptNormal = {
bg = prompt, -- bg = prompt,
} -- }
highlights.TelescopePromptBorder = { -- highlights.TelescopePromptBorder = {
bg = prompt, -- bg = prompt,
fg = prompt, -- fg = prompt,
} -- }
highlights.TelescopePromptTitle = { -- highlights.TelescopePromptTitle = {
bg = prompt, -- bg = prompt,
fg = prompt, -- fg = prompt,
} -- }
highlights.TelescopePreviewTitle = { -- highlights.TelescopePreviewTitle = {
bg = colors.bg_dark, -- bg = colors.bg_dark,
fg = colors.bg_dark, -- fg = colors.bg_dark,
} -- }
highlights.TelescopeResultsTitle = { -- highlights.TelescopeResultsTitle = {
bg = colors.bg_dark, -- bg = colors.bg_dark,
fg = colors.bg_dark, -- fg = colors.bg_dark,
} -- }
end, end,
}) })