update for windows
This commit is contained in:
24
lua/core/autocmds.lua
Normal file
24
lua/core/autocmds.lua
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
local group = vim.api.nvim_create_augroup("IndentFormatOnSave", { clear = true })
|
||||||
|
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
|
group = group,
|
||||||
|
callback = function(args)
|
||||||
|
local ft = vim.bo[args.buf].filetype
|
||||||
|
local indent_filetypes = {
|
||||||
|
c = true,
|
||||||
|
cpp = true,
|
||||||
|
h = true,
|
||||||
|
hpp = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
if not indent_filetypes[ft] then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
local view = vim.fn.winsaveview()
|
||||||
|
vim.api.nvim_buf_call(args.buf, function()
|
||||||
|
vim.cmd("silent keepjumps normal! gg=G")
|
||||||
|
end)
|
||||||
|
vim.fn.winrestview(view)
|
||||||
|
end,
|
||||||
|
})
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
require("core.options")
|
require("core.options")
|
||||||
require("core.keymaps")
|
require("core.keymaps")
|
||||||
|
require("core.autocmds")
|
||||||
require("core.lazy")
|
require("core.lazy")
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
local conform = require("conform")
|
|
||||||
|
|
||||||
conform.setup({
|
|
||||||
formatters_by_ft = {
|
|
||||||
c = { "clang_format" },
|
|
||||||
cpp = { "clang_format" },
|
|
||||||
h = { "clang_format" },
|
|
||||||
hpp = { "clang_format" },
|
|
||||||
},
|
|
||||||
format_on_save = function(bufnr)
|
|
||||||
local ft = vim.bo[bufnr].filetype
|
|
||||||
local cpp_filetypes = {
|
|
||||||
c = true,
|
|
||||||
cpp = true,
|
|
||||||
h = true,
|
|
||||||
hpp = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
if cpp_filetypes[ft] then
|
|
||||||
return {
|
|
||||||
timeout_ms = 1000,
|
|
||||||
lsp_format = "fallback",
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("Format", function()
|
|
||||||
conform.format({
|
|
||||||
async = false,
|
|
||||||
timeout_ms = 1000,
|
|
||||||
lsp_format = "fallback",
|
|
||||||
})
|
|
||||||
end, {})
|
|
||||||
@@ -2,7 +2,9 @@ local dap = require("dap")
|
|||||||
local dapui = require("dapui")
|
local dapui = require("dapui")
|
||||||
|
|
||||||
local function resolve_codelldb()
|
local function resolve_codelldb()
|
||||||
local mason_codelldb = vim.fn.stdpath("data") .. "/mason/bin/codelldb"
|
local is_windows = vim.fn.has("win32") == 1
|
||||||
|
local mason_codelldb = vim.fn.stdpath("data")
|
||||||
|
.. (is_windows and "/mason/bin/codelldb.cmd" or "/mason/bin/codelldb")
|
||||||
if vim.fn.executable(mason_codelldb) == 1 then
|
if vim.fn.executable(mason_codelldb) == 1 then
|
||||||
return mason_codelldb
|
return mason_codelldb
|
||||||
end
|
end
|
||||||
@@ -12,7 +14,7 @@ local function resolve_codelldb()
|
|||||||
return system_codelldb
|
return system_codelldb
|
||||||
end
|
end
|
||||||
|
|
||||||
return "codelldb"
|
return is_windows and "codelldb.cmd" or "codelldb"
|
||||||
end
|
end
|
||||||
|
|
||||||
require("nvim-dap-virtual-text").setup({
|
require("nvim-dap-virtual-text").setup({
|
||||||
|
|||||||
@@ -9,3 +9,7 @@ vim.o.autoread = true
|
|||||||
vim.keymap.set({ "n", "x" }, "<leader>oa", function()
|
vim.keymap.set({ "n", "x" }, "<leader>oa", function()
|
||||||
require("opencode").ask("@this: ", { submit = true })
|
require("opencode").ask("@this: ", { submit = true })
|
||||||
end, { desc = "Ask opencode with selection" })
|
end, { desc = "Ask opencode with selection" })
|
||||||
|
|
||||||
|
vim.keymap.set({ "n", "t" }, "<leader>ot", function()
|
||||||
|
require("opencode").toggle()
|
||||||
|
end, { desc = "Toggle opencode" })
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ if wk.add then
|
|||||||
{ "<leader>f", group = "Find" },
|
{ "<leader>f", group = "Find" },
|
||||||
{ "<leader>m", group = "Build" },
|
{ "<leader>m", group = "Build" },
|
||||||
{ "<leader>o", group = "OpenCode" },
|
{ "<leader>o", group = "OpenCode" },
|
||||||
|
{ "<leader>ot", desc = "Toggle opencode" },
|
||||||
{ "<leader>t", group = "Tests" },
|
{ "<leader>t", group = "Tests" },
|
||||||
{ "<leader>x", group = "Problems" },
|
{ "<leader>x", group = "Problems" },
|
||||||
})
|
})
|
||||||
@@ -33,7 +34,10 @@ else
|
|||||||
d = { name = "+Debug" },
|
d = { name = "+Debug" },
|
||||||
f = { name = "+Find" },
|
f = { name = "+Find" },
|
||||||
m = { name = "+Build" },
|
m = { name = "+Build" },
|
||||||
o = { name = "+OpenCode" },
|
o = {
|
||||||
|
name = "+OpenCode",
|
||||||
|
t = "Toggle opencode",
|
||||||
|
},
|
||||||
t = { name = "+Tests" },
|
t = { name = "+Tests" },
|
||||||
x = { name = "+Problems" },
|
x = { name = "+Problems" },
|
||||||
}, { prefix = "<leader>" })
|
}, { prefix = "<leader>" })
|
||||||
|
|||||||
@@ -68,12 +68,6 @@ return {
|
|||||||
require("plugins.config.cmp")
|
require("plugins.config.cmp")
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"stevearc/conform.nvim",
|
|
||||||
config = function()
|
|
||||||
require("plugins.config.conform")
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
'nvim-telescope/telescope.nvim', tag = '0.1.8',
|
||||||
dependencies = { 'nvim-lua/plenary.nvim' }
|
dependencies = { 'nvim-lua/plenary.nvim' }
|
||||||
|
|||||||
Reference in New Issue
Block a user