feat: Add better terminal
This commit is contained in:
parent
7cacef1705
commit
8633e56645
11 changed files with 107 additions and 95 deletions
|
|
@ -50,10 +50,10 @@ end, opts)
|
|||
|
||||
-- toggle terminal
|
||||
local lazyterm = function()
|
||||
Util.float_term(nil, { cwd = Util.get_root() })
|
||||
Util.terminal(nil, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false })
|
||||
end
|
||||
map("n", "<c-t>", lazyterm, { desc = "Terminal (root dir)" })
|
||||
map("t", "<C-t>", "<cmd>close<cr>", { desc = "Hide Terminal" })
|
||||
map("t", "<c-t>", "<cmd>close<cr>", { desc = "Hide Terminal" })
|
||||
|
||||
-- semicolon thing
|
||||
-- map("i","<C-m>" ,"<C-o>A;<CR>", {desc = "add semi and newline"})
|
||||
|
|
@ -133,6 +133,12 @@ map("n", "<leader>z", function()
|
|||
require("telescope").extensions.zoxide.list({})
|
||||
end, { desc = "Zoxide" })
|
||||
|
||||
-- neoscroll
|
||||
local t = {}
|
||||
t["<A-l>"] = { "scroll", { "-vim.wo.scroll", "true", "250" } }
|
||||
t["<A-k>"] = { "scroll", { "vim.wo.scroll", "true", "250" } }
|
||||
require("neoscroll.config").set_mappings(t)
|
||||
|
||||
-- trouble
|
||||
map("n", "<leader>t", "<cmd>TroubleToggle<CR>", term_opts)
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ require("lazy").setup({
|
|||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins" },
|
||||
{ import = "lazyvim.plugins.extras.ui.alpha" },
|
||||
{ import = "plugins.plugins" },
|
||||
{ import = "plugins" },
|
||||
-- import any extras modules here
|
||||
|
|
@ -47,4 +48,3 @@ require("lazy").setup({
|
|||
},
|
||||
},
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ M._keys = nil
|
|||
---@return (LazyKeys|{has?:string})[]
|
||||
function M.get()
|
||||
local format = function()
|
||||
require("lazyvim.plugins.lsp.format").format({ force = true })
|
||||
require("lazyvim.util").format({ force = true })
|
||||
end
|
||||
if not M._keys then
|
||||
---@class PluginLspKeys
|
||||
|
|
@ -89,7 +89,7 @@ end
|
|||
---@param method string
|
||||
function M.has(buffer, method)
|
||||
method = method:find("/") and method or "textDocument/" .. method
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
if client.supports_method(method) then
|
||||
return true
|
||||
|
|
@ -98,45 +98,33 @@ function M.has(buffer, method)
|
|||
return false
|
||||
end
|
||||
|
||||
---@return (LazyKeys|{has?:string})[]
|
||||
function M.resolve(buffer)
|
||||
local Keys = require("lazy.core.handler.keys")
|
||||
local keymaps = {} ---@type table<string,LazyKeys|{has?:string}>
|
||||
|
||||
local function add(keymap)
|
||||
local keys = Keys.parse(keymap)
|
||||
if keys[2] == false then
|
||||
keymaps[keys.id] = nil
|
||||
else
|
||||
keymaps[keys.id] = keys
|
||||
end
|
||||
if not Keys.resolve then
|
||||
return {}
|
||||
end
|
||||
for _, keymap in ipairs(M.get()) do
|
||||
add(keymap)
|
||||
end
|
||||
|
||||
local spec = M.get()
|
||||
local opts = require("lazyvim.util").opts("nvim-lspconfig")
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
|
||||
for _, keymap in ipairs(maps) do
|
||||
add(keymap)
|
||||
end
|
||||
vim.list_extend(spec, maps)
|
||||
end
|
||||
return keymaps
|
||||
return Keys.resolve(spec)
|
||||
end
|
||||
|
||||
function M.on_attach(client, buffer)
|
||||
function M.on_attach(_, buffer)
|
||||
local Keys = require("lazy.core.handler.keys")
|
||||
local keymaps = M.resolve(buffer)
|
||||
|
||||
for _, keys in pairs(keymaps) do
|
||||
if not keys.has or M.has(buffer, keys.has) then
|
||||
local opts = Keys.opts(keys)
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
opts.has = nil
|
||||
opts.silent = opts.silent ~= false
|
||||
opts.buffer = buffer
|
||||
vim.keymap.set(keys.mode or "n", keys[1], keys[2], opts)
|
||||
vim.keymap.set(keys.mode or "n", keys.lhs, keys.rhs, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ return {
|
|||
for w in rust_dap:gmatch("([^/]+)") do
|
||||
filename = w
|
||||
end
|
||||
filename = filename:gsub("-", "_")
|
||||
filename = string.lower(filename)
|
||||
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,5 +6,6 @@ return {
|
|||
{ "rcarriga/nvim-notify", enabled = false },
|
||||
},
|
||||
{ { "folke/noice.nvim", enabled = false } },
|
||||
{ { "jose-elias-alvarez/null-ls.nvim", enabled = false } },
|
||||
{ { "nvimtools/none-ls.nvim", enabled = false } },
|
||||
{ { "glepnir/dashboard-nvim", enabled = false } },
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,11 +189,17 @@ return {
|
|||
local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"]
|
||||
require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false))
|
||||
end
|
||||
|
||||
-- setup autoformat
|
||||
require("lazyvim.plugins.lsp.format").setup(opts)
|
||||
Util.format.register(Util.lsp.formatter())
|
||||
|
||||
-- deprectaed options
|
||||
if opts.autoformat ~= nil then
|
||||
vim.g.autoformat = opts.autoformat
|
||||
end
|
||||
|
||||
-- setup formatting and keymaps
|
||||
Util.on_attach(function(client, buffer)
|
||||
Util.lsp.on_attach(function(client, buffer)
|
||||
require("config.lsp-keymap").on_attach(client, buffer)
|
||||
end)
|
||||
|
||||
|
|
@ -218,7 +224,7 @@ return {
|
|||
local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
|
||||
|
||||
if opts.inlay_hints.enabled and inlay_hint then
|
||||
Util.on_attach(function(client, buffer)
|
||||
Util.lsp.on_attach(function(client, buffer)
|
||||
if client.supports_method("textDocument/inlayHint") then
|
||||
inlay_hint(buffer, true)
|
||||
end
|
||||
|
|
@ -290,17 +296,17 @@ return {
|
|||
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
|
||||
end
|
||||
|
||||
if Util.lsp_get_config("denols") and Util.lsp_get_config("tsserver") then
|
||||
if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then
|
||||
local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
|
||||
Util.lsp_disable("tsserver", is_deno)
|
||||
Util.lsp_disable("denols", function(root_dir)
|
||||
Util.lsp.disable("tsserver", is_deno)
|
||||
Util.lsp.disable("denols", function(root_dir)
|
||||
return not is_deno(root_dir)
|
||||
end)
|
||||
end
|
||||
|
||||
require("lspconfig").ltex.setup({
|
||||
capabilities = capabilities,
|
||||
on_attach = Util.on_attach(function(client, buffer)
|
||||
on_attach = Util.lsp.on_attach(function(client, buffer)
|
||||
require("config.lsp-keymap").on_attach(client, buffer)
|
||||
require("ltex_extra").setup({
|
||||
path = vim.fn.expand("~") .. "/.local/share/ltex",
|
||||
|
|
|
|||
|
|
@ -124,18 +124,6 @@ return {
|
|||
"karb94/neoscroll.nvim",
|
||||
config = function()
|
||||
require("neoscroll").setup()
|
||||
local t = {}
|
||||
t["<A-l>"] = { "scroll", { "-vim.wo.scroll", "true", "250" } }
|
||||
t["<A-k>"] = { "scroll", { "vim.wo.scroll", "true", "250" } }
|
||||
t["<C-b>"] = { "scroll", { "-vim.api.nvim_win_get_height(0)", "true", "450" } }
|
||||
t["<C-f>"] = { "scroll", { "vim.api.nvim_win_get_height(0)", "true", "450" } }
|
||||
t["<C-y>"] = { "scroll", { "-0.10", "false", "100" } }
|
||||
t["<C-e>"] = { "scroll", { "0.10", "false", "100" } }
|
||||
t["zt"] = { "zt", { "250" } }
|
||||
t["zz"] = { "zz", { "250" } }
|
||||
t["zb"] = { "zb", { "250" } }
|
||||
|
||||
require("neoscroll.config").set_mappings(t)
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue