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 {
"leoluz/nvim-dap-go",
config = function()
local dir = require("utils.finder").find_project_dir("go.mod", 3, { "src", "app", "pkg" }, { "test" }, true)
require("dap-go").setup({ delve = { cwd = dir } })
end,
"leoluz/nvim-dap-go",
config = function()
local dir = require("utils.finder").find_project_dir(
"go.mod",
3,
{ "src", "app", "pkg" },
{ "test" },
true
)
require("dap-go").setup({ delve = { cwd = dir } })
end,
}

View file

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

View file

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

View file

@ -31,43 +31,101 @@ return {
},
},
})
dap.listeners.before.attach.dapui_config = function()
dapui.open()
end
dap.listeners.before.launch.dapui_config = function()
dapui.open()
end
dap.listeners.before.attach.dapui_config = function() dapui.open() end
dap.listeners.before.launch.dapui_config = function() dapui.open() end
-- Keybinding --
vim.keymap.set("n", "<Leader>dt", dapui.toggle, { 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" })
vim.keymap.set(
"n",
"<Leader>dt",
dapui.toggle,
{ 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 --
vim.api.nvim_set_hl(0, "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.api.nvim_set_hl(
0,
"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(
"DapBreakpoint",
{ text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
{
text = "",
texthl = "DapBreakpoint",
linehl = "DapBreakpoint",
numhl = "DapBreakpoint",
}
)
vim.fn.sign_define(
"DapBreakpointCondition",
{ text = "󰣏", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
{
text = "󰣏",
texthl = "DapBreakpoint",
linehl = "DapBreakpoint",
numhl = "DapBreakpoint",
}
)
vim.fn.sign_define(
"DapBreakpointRejected",
{ text = "", texthl = "DapBreakpoint", linehl = "DapBreakpoint", numhl = "DapBreakpoint" }
{
text = "",
texthl = "DapBreakpoint",
linehl = "DapBreakpoint",
numhl = "DapBreakpoint",
}
)
vim.fn.sign_define(
"DapLogPoint",
{ text = "", texthl = "DapLogPoint", linehl = "DapLogPoint", numhl = "DapLogPoint" }
{
text = "",
texthl = "DapLogPoint",
linehl = "DapLogPoint",
numhl = "DapLogPoint",
}
)
vim.fn.sign_define(
"DapStopped",
{ text = "", texthl = "DapStopped", linehl = "DapStopped", numhl = "DapStopped" }
{
text = "",
texthl = "DapStopped",
linehl = "DapStopped",
numhl = "DapStopped",
}
)
end,
},

View file

@ -1,5 +1,6 @@
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 web_lsp = require("plugins.editor.language_server.language_server_web")
local php_lsp = require("plugins.editor.language_server.language_server_php")
@ -8,9 +9,7 @@ return {
{
"williamboman/mason.nvim",
lazy = false,
config = function()
require("mason").setup()
end,
config = function() require("mason").setup() end,
},
{
"williamboman/mason-lspconfig.nvim",
@ -45,10 +44,30 @@ return {
php_lsp.setup(lspconfig, capabilities)
-- Keybinding --
vim.keymap.set("n", "<leader>cd", 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" })
vim.keymap.set(
"n",
"<leader>cd",
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,
},
{
@ -71,7 +90,12 @@ return {
})
-- 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,
},
{
@ -86,9 +110,24 @@ return {
lspsaga.setup({})
-- Keybinding --
vim.keymap.set("n", "<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" })
vim.keymap.set(
"n",
"<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,
},
}

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,
}

View file

@ -34,12 +34,19 @@ local function get_dap_repl_winbar(active)
return ""
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 .. "#"
for element in require("dapui.controls").controls():gmatch("%S+") do
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
return controls_string
end

View file

@ -65,7 +65,17 @@ return {
})
-- Keybinding --
vim.keymap.set("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" })
vim.keymap.set(
"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,
}

View file

@ -9,14 +9,24 @@ return {
require("gitsigns").setup()
-- 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(
"n",
"<leader>gb",
":Gitsigns toggle_current_line_blame<CR>",
{ 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,
},
{

View file

@ -17,9 +17,18 @@ return {
require("telescope").load_extension("ui-select")
-- Keybinding --
local function setTelescopeBinding(mode, keymap, method, search_global, description)
local function setTelescopeBinding(
mode,
keymap,
method,
search_global,
description
)
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 } })
end
vim.keymap.set(mode, keymap, binding, { desc = description })
@ -27,9 +36,33 @@ return {
local telescope = require("telescope.builtin")
setTelescopeBinding("n", "<leader>ff", 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")
setTelescopeBinding(
"n",
"<leader>ff",
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,
}

View file

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