Add Stylua config to nvim conf

This commit is contained in:
Snoweuph 2024-06-02 19:45:00 +02:00
parent 7e4d0339de
commit 1e1d5d264a
Signed by: Snoweuph
GPG key ID: A494330694B208EF
12 changed files with 233 additions and 61 deletions

View file

@ -1,7 +1,13 @@
return { return {
"leoluz/nvim-dap-go", "leoluz/nvim-dap-go",
config = function() config = function()
local dir = require("utils.finder").find_project_dir("go.mod", 3, { "src", "app", "pkg" }, { "test" }, true) local dir = require("utils.finder").find_project_dir(
"go.mod",
3,
{ "src", "app", "pkg" },
{ "test" },
true
)
require("dap-go").setup({ delve = { cwd = dir } }) require("dap-go").setup({ delve = { cwd = dir } })
end, end,
} }

View file

@ -1,6 +1,4 @@
return { return {
"m4xshen/autoclose.nvim", "m4xshen/autoclose.nvim",
config = function() config = function() require("autoclose").setup() end,
require("autoclose").setup()
end,
} }

View file

@ -40,9 +40,12 @@ return {
end end
end, { silent = true }) end, { silent = true })
vim.keymap.set({ "i", "s" }, "<S-Tab>", function() vim.keymap.set(
luasnip.jump(-1) { "i", "s" },
end, { silent = true }) "<S-Tab>",
function() luasnip.jump(-1) end,
{ silent = true }
)
local doc_keybindings = { local doc_keybindings = {
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
@ -55,9 +58,7 @@ return {
-- Setup -- -- Setup --
cmp.setup({ cmp.setup({
snippet = { snippet = {
expand = function(args) expand = function(args) luasnip.lsp_expand(args.body) end,
luasnip.lsp_expand(args.body)
end,
}, },
window = { window = {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),

View file

@ -31,43 +31,101 @@ return {
}, },
}, },
}) })
dap.listeners.before.attach.dapui_config = function() dap.listeners.before.attach.dapui_config = function() dapui.open() end
dapui.open() dap.listeners.before.launch.dapui_config = function() dapui.open() end
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
-- Keybinding -- -- Keybinding --
vim.keymap.set("n", "<Leader>dt", dapui.toggle, { desc = "Toggle Debugger UI" }) vim.keymap.set(
vim.keymap.set("n", "<Leader>db", dap.toggle_breakpoint, { desc = "Toggle Breakpoint" }) "n",
vim.keymap.set("n", "<Leader>dc", dap.continue, { desc = "Debugger Continue" }) "<Leader>dt",
vim.keymap.set("n", "<Leader>dx", dap.terminate, { desc = "Debugger Terminate" }) dapui.toggle,
vim.keymap.set("n", "<Leader>ds", dap.step_over, { desc = "Debugger Step Over" }) { desc = "Toggle Debugger UI" }
)
vim.keymap.set(
"n",
"<Leader>db",
dap.toggle_breakpoint,
{ desc = "Toggle Breakpoint" }
)
vim.keymap.set(
"n",
"<Leader>dc",
dap.continue,
{ desc = "Debugger Continue" }
)
vim.keymap.set(
"n",
"<Leader>dx",
dap.terminate,
{ desc = "Debugger Terminate" }
)
vim.keymap.set(
"n",
"<Leader>ds",
dap.step_over,
{ desc = "Debugger Step Over" }
)
-- Breakpoints -- -- Breakpoints --
vim.api.nvim_set_hl(0, "DapBreakpoint", { ctermbg = 0, fg = "#993939", bg = "#31353f" }) vim.api.nvim_set_hl(
vim.api.nvim_set_hl(0, "DapLogPoint", { ctermbg = 0, fg = "#61afef", bg = "#31353f" }) 0,
vim.api.nvim_set_hl(0, "DapStopped", { ctermbg = 0, fg = "#98c379", bg = "#31353f" }) "DapBreakpoint",
{ ctermbg = 0, fg = "#993939", bg = "#31353f" }
)
vim.api.nvim_set_hl(
0,
"DapLogPoint",
{ ctermbg = 0, fg = "#61afef", bg = "#31353f" }
)
vim.api.nvim_set_hl(
0,
"DapStopped",
{ ctermbg = 0, fg = "#98c379", bg = "#31353f" }
)
vim.fn.sign_define( vim.fn.sign_define(
"DapBreakpoint", "DapBreakpoint",
{ text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } {
text = "",
texthl = "DapBreakpoint",
linehl = "DapBreakpoint",
numhl = "DapBreakpoint",
}
) )
vim.fn.sign_define( vim.fn.sign_define(
"DapBreakpointCondition", "DapBreakpointCondition",
{ text = "󰣏", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } {
text = "󰣏",
texthl = "DapBreakpoint",
linehl = "DapBreakpoint",
numhl = "DapBreakpoint",
}
) )
vim.fn.sign_define( vim.fn.sign_define(
"DapBreakpointRejected", "DapBreakpointRejected",
{ text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" } {
text = "",
texthl = "DapBreakpoint",
linehl = "DapBreakpoint",
numhl = "DapBreakpoint",
}
) )
vim.fn.sign_define( vim.fn.sign_define(
"DapLogPoint", "DapLogPoint",
{ text = "", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" } {
text = "",
texthl = "DapLogPoint",
linehl = "DapLogPoint",
numhl = "DapLogPoint",
}
) )
vim.fn.sign_define( vim.fn.sign_define(
"DapStopped", "DapStopped",
{ text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" } {
text = "",
texthl = "DapStopped",
linehl = "DapStopped",
numhl = "DapStopped",
}
) )
end, end,
}, },

View file

@ -1,5 +1,6 @@
local lua_lsp = require("plugins.editor.language_server.language_server_lua") local lua_lsp = require("plugins.editor.language_server.language_server_lua")
local generic_lsp = require("plugins.editor.language_server.language_server_generic") local generic_lsp =
require("plugins.editor.language_server.language_server_generic")
local go_lsp = require("plugins.editor.language_server.language_server_go") local go_lsp = require("plugins.editor.language_server.language_server_go")
local web_lsp = require("plugins.editor.language_server.language_server_web") local web_lsp = require("plugins.editor.language_server.language_server_web")
local php_lsp = require("plugins.editor.language_server.language_server_php") local php_lsp = require("plugins.editor.language_server.language_server_php")
@ -8,9 +9,7 @@ return {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
lazy = false, lazy = false,
config = function() config = function() require("mason").setup() end,
require("mason").setup()
end,
}, },
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
@ -45,10 +44,30 @@ return {
php_lsp.setup(lspconfig, capabilities) php_lsp.setup(lspconfig, capabilities)
-- Keybinding -- -- Keybinding --
vim.keymap.set("n", "<leader>cd", vim.lsp.buf.hover, { desc = "Show Code Definition" }) vim.keymap.set(
vim.keymap.set("n", "<leader>gd", vim.lsp.buf.definition, { desc = "Go to Definition" }) "n",
vim.keymap.set("n", "<leader>gr", vim.lsp.buf.references, { desc = "Go to References" }) "<leader>cd",
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, { desc = "Do Code Actions" }) vim.lsp.buf.hover,
{ desc = "Show Code Definition" }
)
vim.keymap.set(
"n",
"<leader>gd",
vim.lsp.buf.definition,
{ desc = "Go to Definition" }
)
vim.keymap.set(
"n",
"<leader>gr",
vim.lsp.buf.references,
{ desc = "Go to References" }
)
vim.keymap.set(
"n",
"<leader>ca",
vim.lsp.buf.code_action,
{ desc = "Do Code Actions" }
)
end, end,
}, },
{ {
@ -71,7 +90,12 @@ return {
}) })
-- Keybinding -- -- Keybinding --
vim.keymap.set("n", "<leader>fc", vim.lsp.buf.format, { desc = "Format Code" }) vim.keymap.set(
"n",
"<leader>fc",
vim.lsp.buf.format,
{ desc = "Format Code" }
)
end, end,
}, },
{ {
@ -86,9 +110,24 @@ return {
lspsaga.setup({}) lspsaga.setup({})
-- Keybinding -- -- Keybinding --
vim.keymap.set("n", "<leader>cr", ":Lspsaga rename<CR>", { desc = "Rename Variable" }) vim.keymap.set(
vim.keymap.set("n", "<leader>cp", ":Lspsaga peek_definition<CR>", { desc = "Peek Code Definition" }) "n",
vim.keymap.set({ "n", "t" }, "<F6>", "<cmd>Lspsaga term_toggle<CR>", { desc = "Toggle Terminal" }) "<leader>cr",
":Lspsaga rename<CR>",
{ desc = "Rename Variable" }
)
vim.keymap.set(
"n",
"<leader>cp",
":Lspsaga peek_definition<CR>",
{ desc = "Peek Code Definition" }
)
vim.keymap.set(
{ "n", "t" },
"<F6>",
"<cmd>Lspsaga term_toggle<CR>",
{ desc = "Toggle Terminal" }
)
end, end,
}, },
} }

View file

@ -25,6 +25,11 @@ return {
}, },
}) })
vim.keymap.set("n", "<Leader>mp", ":Mdpreview<CR>", { desc = "Show Markdown Preview" }) vim.keymap.set(
"n",
"<Leader>mp",
":Mdpreview<CR>",
{ desc = "Show Markdown Preview" }
)
end, end,
} }

View file

@ -34,12 +34,19 @@ local function get_dap_repl_winbar(active)
return "" return ""
end end
local background_color = string.format("lualine_b" .. "%s", active and get_mode() or "_inactive") local background_color = string.format(
"lualine_b" .. "%s",
active and get_mode() or "_inactive"
)
local controls_string = "%#" .. background_color .. "#" local controls_string = "%#" .. background_color .. "#"
for element in require("dapui.controls").controls():gmatch("%S+") do for element in require("dapui.controls").controls():gmatch("%S+") do
local color, action = string.match(element, "%%#(.*)#(%%.*)%%#0#") local color, action = string.match(element, "%%#(.*)#(%%.*)%%#0#")
controls_string = controls_string .. " %#" .. merge_colors(color, background_color) .. "#" .. action controls_string = controls_string
.. " %#"
.. merge_colors(color, background_color)
.. "#"
.. action
end end
return controls_string return controls_string
end end

View file

@ -65,7 +65,17 @@ return {
}) })
-- Keybinding -- -- Keybinding --
vim.keymap.set("n", "<leader>ft", ":Neotree toggle reveal left<CR>", { desc = "Toggle File Tree" }) vim.keymap.set(
vim.keymap.set("n", "<leader>fo", ":Neotree buffers reveal float<CR>", { desc = "Show Open Files" }) "n",
"<leader>ft",
":Neotree toggle reveal left<CR>",
{ desc = "Toggle File Tree" }
)
vim.keymap.set(
"n",
"<leader>fo",
":Neotree buffers reveal float<CR>",
{ desc = "Show Open Files" }
)
end, end,
} }

View file

@ -9,14 +9,24 @@ return {
require("gitsigns").setup() require("gitsigns").setup()
-- Keybinding -- -- Keybinding --
vim.keymap.set("n", "<leader>gh", ":Gitsigns preview_hunk_inline<CR>", { desc = "Toggle Inline Git Diff" }) vim.keymap.set(
"n",
"<leader>gh",
":Gitsigns preview_hunk_inline<CR>",
{ desc = "Toggle Inline Git Diff" }
)
vim.keymap.set( vim.keymap.set(
"n", "n",
"<leader>gb", "<leader>gb",
":Gitsigns toggle_current_line_blame<CR>", ":Gitsigns toggle_current_line_blame<CR>",
{ desc = "Toggle Inline Git Blame" } { desc = "Toggle Inline Git Blame" }
) )
vim.keymap.set("n", "<leader>go", ":Git <CR>", { desc = "Open Git" }) vim.keymap.set(
"n",
"<leader>go",
":Git <CR>",
{ desc = "Open Git" }
)
end, end,
}, },
{ {

View file

@ -17,9 +17,18 @@ return {
require("telescope").load_extension("ui-select") require("telescope").load_extension("ui-select")
-- Keybinding -- -- Keybinding --
local function setTelescopeBinding(mode, keymap, method, search_global, description) local function setTelescopeBinding(
mode,
keymap,
method,
search_global,
description
)
local function binding() local function binding()
local path = search_global and "~" or require("neo-tree.sources.manager").get_state("filesystem").path local path = search_global and "~"
or require("neo-tree.sources.manager").get_state(
"filesystem"
).path
method({ search_dirs = { path } }) method({ search_dirs = { path } })
end end
vim.keymap.set(mode, keymap, binding, { desc = description }) vim.keymap.set(mode, keymap, binding, { desc = description })
@ -27,9 +36,33 @@ return {
local telescope = require("telescope.builtin") local telescope = require("telescope.builtin")
setTelescopeBinding("n", "<leader>ff", telescope.find_files, false, "Find File") setTelescopeBinding(
setTelescopeBinding("n", "<leader>fz", telescope.live_grep, false, "Fuzzy Find") "n",
setTelescopeBinding("n", "<leader>gff", telescope.find_files, true, "Global Find File") "<leader>ff",
setTelescopeBinding("n", "<leader>gfz", telescope.live_grep, true, "Global Fuzzy Find") telescope.find_files,
false,
"Find File"
)
setTelescopeBinding(
"n",
"<leader>fz",
telescope.live_grep,
false,
"Fuzzy Find"
)
setTelescopeBinding(
"n",
"<leader>gff",
telescope.find_files,
true,
"Global Find File"
)
setTelescopeBinding(
"n",
"<leader>gfz",
telescope.live_grep,
true,
"Global Fuzzy Find"
)
end, end,
} }

View file

@ -72,8 +72,6 @@ return {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
"nvim-tree/nvim-web-devicons", "nvim-tree/nvim-web-devicons",
}, },
config = function() config = function() require("barbar").setup() end,
require("barbar").setup()
end,
}, },
} }

7
.config/nvim/stylua.toml Normal file
View file

@ -0,0 +1,7 @@
column_width = 80
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"
collapse_simple_statement = "FunctionOnly"