This commit is contained in:
sudacode 2025-02-15 01:17:09 -08:00
parent c839993a25
commit f1d8f5f834
Signed by: sudacode
SSH Key Fingerprint: SHA256:lT5C2bB398DcX6daCF/gYFNSTK3y+Du3oTGUnYzfTEw
5 changed files with 197 additions and 130 deletions

View File

@ -63,3 +63,28 @@ vim.cmd([[
-- end
-- end
-- })
local function set_timeoutlen_for_insert_mode()
if vim.bo.buftype == "terminal" or vim.bo.filetype == "codecompanion" then
vim.o.timeoutlen = 0
else
vim.o.timeoutlen = 300 -- Default timeoutlen for other buffers
end
end
-- Create an augroup for managing the autocmds
local augroup = vim.api.nvim_create_augroup("InsertModeTimeout", { clear = true })
-- Autocommand to adjust timeoutlen when entering insert mode
vim.api.nvim_create_autocmd("InsertEnter", {
group = augroup,
callback = set_timeoutlen_for_insert_mode,
})
-- Autocommand to reset timeoutlen when leaving insert mode
vim.api.nvim_create_autocmd("InsertLeave", {
group = augroup,
callback = function()
vim.o.timeoutlen = 300
end,
})

View File

@ -83,23 +83,35 @@ end
map("v", "op", "<C-\\><C-N>:ToggleTerm name=ipython")
map("v", "oP", "<C-\\><C-N>:ToggleTerm name=ipython-full")
map("t", "<leader>tp", "<C-\\><C-N>:FloatermToggle ipython<CR>", opts)
map("t", "<leader>tP", "<C-\\><C-N>:FloatermToggle ipython-full<CR>", opts)
map("n", "<C-T>", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>tt", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>tT", ":ToggleTerm name=toggleterm-full direction=tab<CR>", opts)
map("n", "<leader>ts", ":TermSelect<CR>", opts)
map("n", "<leader>tv", ":ToggleTerm direction=vertical name=toggleterm-vert<CR>", opts)
map("n", "<leader>th", ":ToggleTerm direction=horizontal name=toggleterm-hori<CR>", opts)
map("n", "<leader>tf", ":ToggleTerm name=toggleterm<CR>", opts)
map("n", "<leader>-", "<C-\\><C-N>:ToggleTerm direction='horizontal'<CR>", opts)
map("n", "<leader>|", "<C-\\><C-N>:ToggleTerm direction='vertical'<CR>", opts)
map("t", "<leader>tt", "<C-\\><C-N>:ToggleTerm<CR>", opts)
map("t", "<leader>tf", "<C-\\><C-N>:ToggleTerm<CR>", opts)
map("t", "<leader>tv", "<C-\\><C-N>:ToggleTerm --name=toggleterm-vert<CR>", opts)
map("t", "<leader>th", "<C-\\><C-N>:ToggleTerm --name=toggleterm-hori<CR>", opts)
map("t", "<C-T>", "<C-\\><C-n>:Toggleterm<CR>", opts)
map("t", "<Esc>", "<C-\\><C-n>", opts)
map("t", "<space>", "<space>", opts) -- fix space in terminal
-- map("t", "<leader>tt", "<C-\\><C-N>:ToggleTerm<CR>", opts)
-- map("t", "<leader>tf", "<C-\\><C-N>:ToggleTerm<CR>", opts)
-- map("t", "<leader>-", "<C-\\><C-N>:ToggleTerm direction='horizontal'<CR>", opts)
-- map("t", "<leader>|", "<C-\\><C-N>:ToggleTerm direction='vertical'<CR>", opts)
-- map("t", "<leader>tv", "<C-\\><C-N>:ToggleTerm --name=toggleterm-vert<CR>", opts)
-- map("t", "<leader>th", "<C-\\><C-N>:ToggleTerm --name=toggleterm-hori<CR>", opts)
-- map("t", "<C-T>", "<C-\\><C-n>:Toggleterm<CR>", opts)
-- map("t", "<Esc>", "<C-\\><C-n>", opts)
-- map("n", "<space>", "<nop>", opts) -- fix space in terminal
function _G.set_terminal_keymaps()
local opts = { buffer = 0 }
map("t", "<esc>", [[<C-\><C-n>]], opts)
map("t", "<C-w>", [[<C-\><C-n><C-w>]], opts)
-- map("t", "<space>", "<space>", { buffer = 0, silent = true }) -- fix space in terminal
end
-- if you only want these mappings for toggle term use term://*toggleterm#* instead
vim.cmd("autocmd! TermOpen term://* lua set_terminal_keymaps()")
--}}}
--{{{ LSP mappings
@ -140,7 +152,7 @@ map("v", "<leader>CT", ":CodeCompanion /tests<CR>", opts)
map("n", "<leader>cd", ":Telescope diagnostics<CR>")
map("n", "<leader>cDn", ":lua vim.diagnostic.goto_next()<CR>")
map("n", "<leader>cDp", ":lua vim.diagnostic.goto_prev()<CR<CR>")
map("n", "<leader>cd", ":lua vim.diagnostic.setloclist()<CR>")
map("n", "<leader>cl", ":lua vim.diagnostic.setloclist()<CR>")
--}}}
--{{{ Telescope mappings
@ -217,7 +229,7 @@ end, opts)
--{{{ LSP
map("n", "<leader>ld", ":Telescope lsp_definitions<CR>")
map("n", "<leader>lD", ":Telescope diagnostic<CR>")
map("n", "<leader>la", ":lua vim.lsp.buf.code_action()<CR>")
map("n", "<leader>la", vim.lsp.buf.code_action)
map("n", "<leader>lci", ":Telescope lsp_incoming_calls<CR>")
map("n", "<leader>lco", ":Telescope lsp_outgoing_calls<CR>")
map("n", "<leader>lh", ":lua vim.lsp.buf.signature_help()<CR>")

View File

@ -235,6 +235,35 @@ require("packer").startup(function(use)
use({ "rcarriga/nvim-notify" })
use({ "stevearc/dressing.nvim" })
use({ "echasnovski/mini.nvim" })
use({
"windwp/nvim-autopairs",
event = "InsertEnter",
config = function()
local npairs = require("nvim-autopairs")
local Rule = require("nvim-autopairs.rule")
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
npairs.setup({
disable_filetype = { "TelescopePrompt", "spectre_panel", "Terminal", "terminal" },
check_ts = true,
ts_config = {
lua = { "string" }, -- it will not add a pair on that treesitter node
javascript = { "template_string" },
java = false, -- don't check treesitter on java
},
})
local ts_conds = require("nvim-autopairs.ts-conds")
-- press % => %% only while inside a comment or string
npairs.add_rules({
Rule("%", "%", "lua"):with_pair(ts_conds.is_ts_node({ "string", "comment" })),
Rule("$", "$", "lua"):with_pair(ts_conds.is_not_ts_node({ "function" })),
})
end,
})
-- }}}
@ -258,7 +287,6 @@ require("packer").startup(function(use)
})
end,
})
use("jiangmiao/auto-pairs")
use("pechorin/any-jump.vim")
use("tpope/vim-commentary")
use("tpope/vim-dotenv")

View File

@ -19,7 +19,7 @@ require("null-ls").setup({
bufnr = bufnr,
filter = function(client)
return client.name == "null-ls"
end
end,
})
end,
})
@ -32,16 +32,16 @@ require("null-ls").setup({
null_ls.builtins.diagnostics.mypy,
null_ls.builtins.diagnostics.markdownlint,
null_ls.builtins.diagnostics.pylint,
null_ls.builtins.diagnostics.pydoclint,
-- null_ls.builtins.diagnostics.pydoclint,
null_ls.builtins.formatting.stylua,
null_ls.builtins.formatting.markdownlint,
null_ls.builtins.formatting.prettier, -- handled by lsp server
null_ls.builtins.formatting.shfmt.with({
filetypes = { "sh", "bash" },
extra_args = { "-i", "0", "-ci", "-sr" }
extra_args = { "-i", "0", "-ci", "-sr" },
}),
-- null_ls.builtins.diagnostics.actionlint,
}
},
})
-- null_ls.setup({

View File

@ -1,4 +1,4 @@
require("toggleterm").setup {
require("toggleterm").setup({
-- size can be a number or function which is passed the current terminal
size = function(term)
if term.direction == "horizontal" then
@ -7,7 +7,7 @@ require("toggleterm").setup {
return vim.o.columns * 0.45
end
end,
open_mapping = { [[<c-t>]], [[<leader>tt]] }, -- or { [[<c-\>]], [[<c-¥>]] } if you also use a Japanese keyboard.
open_mapping = { [[<c-t>]] }, -- or { [[<c-\>]], [[<c-¥>]] } if you also use a Japanese keyboard.
-- on_create = fun(t: Terminal), -- function to run when the terminal is first created
-- on_open = fun(t: Terminal), -- function to run when the terminal opens
-- on_close = fun(t: Terminal), -- function to run when the terminal closes
@ -24,7 +24,7 @@ require("toggleterm").setup {
guibg = "#24273A",
},
NormalFloat = {
link = 'Normal'
link = "Normal",
},
-- FloatBorder = {
-- guifg = "<VALUE-HERE>",
@ -40,7 +40,7 @@ require("toggleterm").setup {
persist_size = false,
persist_mode = true, -- if set to true (default) the previous terminal mode will be remembered
-- direction = 'vertical' | 'horizontal' | 'tab' | 'float',
direction = 'float',
direction = "float",
-- close_on_exit = true, -- close the terminal window when the process exits
-- clear_env = false, -- use only environmental variables from `env`, passed to jobstart()
-- Change the default shell. Can be a string or a function returning a string
@ -53,27 +53,29 @@ require("toggleterm").setup {
-- the 'curved' border is a custom border type
-- not natively supported but implemented in this plugin.
-- border = 'single' | 'double' | 'shadow' | 'curved' | ... other options supported by win open
border = 'curved',
border = "curved",
-- like `size`, width, height, row, and col can be a number or function which is passed the current terminal
width = vim.o.columns * 0.8,
width = function()
return vim.o.columns - 35
end,
-- height = 75,
-- row = <value>,
-- col = vim.o.columns * 0.8,
winblend = 3,
zindex = 10,
-- title_pos = 'left' | 'center' | 'right', position of the title of the floating window
title_pos = 'center',
title_pos = "center",
},
winbar = {
enabled = true,
enabled = false,
name_formatter = function(term) -- term: Terminal
return term.name
end
end,
},
responsiveness = {
-- breakpoint in terms of `vim.o.columns` at which terminals will start to stack on top of each other
-- instead of next to each other
-- default = 0 which means the feature is turned off
horizontal_breakpoint = 135,
}
}
},
})