chore: cleanup code
This commit is contained in:
parent
3e876355b2
commit
61b1076625
8 changed files with 100 additions and 95 deletions
|
|
@ -1,17 +1,3 @@
|
|||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
-- Add any additional autocmds here
|
||||
-- local function augroup(name)
|
||||
-- return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
|
||||
-- end
|
||||
-- vim.api.nvim_create_autocmd("TextYankPost", {
|
||||
-- group = augroup("toggle_relative_group"),
|
||||
-- callback = function(_)
|
||||
-- vim.cmd("set norelativenumber")
|
||||
-- end,
|
||||
-- })
|
||||
-- nvim-tree is also there in modified buffers so this function filter it out
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(ev)
|
||||
local client = vim.lsp.get_client_by_id(ev.data.client_id)
|
||||
|
|
@ -34,7 +20,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||
|
||||
local modifiedBufs = function(bufs)
|
||||
local t = 0
|
||||
for k, v in pairs(bufs) do
|
||||
for _, v in pairs(bufs) do
|
||||
if v.name:match("NvimTree_") == nil then
|
||||
t = t + 1
|
||||
end
|
||||
|
|
|
|||
|
|
@ -42,10 +42,10 @@ map("n", "<C-t>", function()
|
|||
end, { desc = "Toggle Terminal" })
|
||||
|
||||
-- semicolon thing
|
||||
map("i","<C-m>" ,"<C-o>A;<CR>", {desc = "add semi and newline"})
|
||||
map("i","<C-n>" ,"<C-o>A;<ESC>", {desc = "add semi"})
|
||||
map("n","<leader>m" ,"$a;<CR>", {desc = "add semi and newline"})
|
||||
map("n","<leader>n" ,"$a;<ESC>", {desc = "add semi"})
|
||||
-- map("i","<C-m>" ,"<C-o>A;<CR>", {desc = "add semi and newline"})
|
||||
-- map("i","<C-n>" ,"<C-o>A;<ESC>", {desc = "add semi"})
|
||||
map("n", "<leader>m", "$a;<CR>", { desc = "add semi and newline" })
|
||||
map("n", "<leader>n", "$a;<ESC>", { desc = "add semi" })
|
||||
|
||||
-- tab switching
|
||||
map("n", "<F1>", ":BufferLineCyclePrev<CR>", opts)
|
||||
|
|
@ -73,6 +73,10 @@ end, { desc = "gitui (root dir)" })
|
|||
map("n", "<leader>gG", function()
|
||||
Util.float_term({ "gitui" })
|
||||
end, { desc = "gitui (cwd)" })
|
||||
map("n", "<leader>gb", function()
|
||||
require("gitblame")
|
||||
vim.cmd(":GitBlameToggle")
|
||||
end, { desc = "gitui (cwd)" })
|
||||
|
||||
-- window switching
|
||||
function _G.set_terminal_maps()
|
||||
|
|
|
|||
|
|
@ -28,14 +28,24 @@ function M.get()
|
|||
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
|
||||
{ "<F4>", format, desc = "Format Document", has = "documentFormatting" },
|
||||
-- { "<leader>cf", format, desc = "Format Range", mode = "v", has = "documentRangeFormatting" },
|
||||
{ "<leader>cq", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
|
||||
{ "<leader>cq",function()
|
||||
vim.lsp.buf.code_action({
|
||||
context = {
|
||||
only = {
|
||||
"quickfix",
|
||||
"source",
|
||||
},
|
||||
diagnostics = {},
|
||||
},
|
||||
})
|
||||
end, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
|
||||
{
|
||||
"<leader>cA",
|
||||
function()
|
||||
vim.lsp.buf.code_action({
|
||||
context = {
|
||||
only = {
|
||||
"source",
|
||||
"refactor",
|
||||
},
|
||||
diagnostics = {},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ return {
|
|||
},
|
||||
config = function(_, opts)
|
||||
require("mason-nvim-dap").setup(opts)
|
||||
require("mason-nvim-dap").setup_handlers({
|
||||
javadbg = function() end,
|
||||
})
|
||||
-- require("mason-nvim-dap").setup_handlers({
|
||||
-- javadbg = function() end,
|
||||
-- })
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
|
|
|||
|
|
@ -70,6 +70,12 @@ return {
|
|||
marksman = {},
|
||||
asm_lsp = {},
|
||||
omnisharp = {},
|
||||
rust_analyzer = {
|
||||
diagnostics = {
|
||||
enable = true,
|
||||
experimental = true,
|
||||
},
|
||||
},
|
||||
tsserver = {
|
||||
settings = {
|
||||
typescript = {
|
||||
|
|
@ -143,18 +149,15 @@ return {
|
|||
jdtls = function()
|
||||
return true
|
||||
end,
|
||||
rust_analyzer = function()
|
||||
return true
|
||||
end,
|
||||
},
|
||||
},
|
||||
config = function(plugin, opts)
|
||||
config = function(_, opts)
|
||||
-- setup autoformat
|
||||
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
|
||||
-- setup formatting and keymaps
|
||||
require("lazyvim.util").on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||
require("config.lsp-keymap").on_attach(client, bufnr)
|
||||
require("config.lsp-keymap").on_attach(client, buffer)
|
||||
end)
|
||||
|
||||
-- diagnostics
|
||||
|
|
@ -166,13 +169,17 @@ return {
|
|||
|
||||
require("lsp-inlayhints").setup({})
|
||||
local servers = opts.servers
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
require("cmp_nvim_lsp").default_capabilities(),
|
||||
opts.capabilities or {}
|
||||
)
|
||||
local on_attach = function(client, bufnr)
|
||||
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
||||
vim.api.nvim_buf_set_option(bufnr, "tagfunc", "v:lua.vim.lsp.tagfunc")
|
||||
local optslsp = { noremap = false, silent = true, buffer = bufnr }
|
||||
require("lsp-inlayhints").on_attach(client, bufnr)
|
||||
-- keymaps
|
||||
require("lsp-inlayhints").on_attach(client, bufnr, true)
|
||||
end
|
||||
|
||||
local function setup(server)
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@ return {
|
|||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
cmd = "Telescope",
|
||||
keys = function() return {} end,
|
||||
keys = function()
|
||||
return {}
|
||||
end,
|
||||
config = function(opts)
|
||||
require("telescope").setup(opts)
|
||||
end,
|
||||
|
|
@ -217,4 +219,8 @@ return {
|
|||
wk.register(opts.defaults)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"f-person/git-blame.nvim",
|
||||
lazy = true,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue