Added initial nvim config
This commit is contained in:
parent
aca7a8c3bb
commit
5d0ed8da19
15 changed files with 282 additions and 0 deletions
7
.config/nvim/lua/plugins/gitsigns.lua
Normal file
7
.config/nvim/lua/plugins/gitsigns.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
"lewis6991/gitsigns.nvim",
|
||||
opt = {
|
||||
current_line_blame = false,
|
||||
},
|
||||
-- TODO: Update
|
||||
}
|
||||
7
.config/nvim/lua/plugins/indent-blankline.lua
Normal file
7
.config/nvim/lua/plugins/indent-blankline.lua
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
return {
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
main = "ibl",
|
||||
---@module "ibl"
|
||||
---@type ibl.config
|
||||
opts = {},
|
||||
}
|
||||
121
.config/nvim/lua/plugins/lsp.lua
Normal file
121
.config/nvim/lua/plugins/lsp.lua
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
cmd = "Mason",
|
||||
},
|
||||
{
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
config = function()
|
||||
require("mason").setup()
|
||||
|
||||
require("mason-lspconfig").setup_handlers({
|
||||
-- The first entry (without a key) will be the default handler
|
||||
-- and will be called for each installed server that doesn't have
|
||||
-- a dedicated handler.
|
||||
function(server_name) -- default handler (optional)
|
||||
require("lspconfig")[server_name].setup({})
|
||||
end,
|
||||
-- Next, you can provide a dedicated handler for specific servers.
|
||||
-- For example, a handler override for the `rust_analyzer`:
|
||||
-- ["rust_analyzer"] = function ()
|
||||
-- require("rust-tools").setup {}
|
||||
-- end
|
||||
})
|
||||
end,
|
||||
},
|
||||
"neovim/nvim-lspconfig",
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
event = { "BufWritePre" },
|
||||
cmd = { "ConformInfo" },
|
||||
opts = function()
|
||||
local mason_reg = require("mason-registry")
|
||||
|
||||
local formatters = {}
|
||||
local formatters_by_ft = {}
|
||||
|
||||
-- add diff langue vs filetype
|
||||
local keymap = {
|
||||
["c++"] = "cpp",
|
||||
["c#"] = "cs",
|
||||
}
|
||||
|
||||
-- add dif conform vs mason
|
||||
local name_map = {
|
||||
["cmakelang"] = "cmake_format",
|
||||
["deno"] = "deno_fmt",
|
||||
["elm-format"] = "elm_format",
|
||||
["gdtoolkit"] = "gdformat",
|
||||
["nixpkgs-fmt"] = "nixpkgs_fmt",
|
||||
["opa"] = "opa_fmt",
|
||||
["php-cs-fixer"] = "php_cs_fixer",
|
||||
["ruff"] = "ruff_format",
|
||||
["sql-formatter"] = "sql_formatter",
|
||||
["xmlformatter"] = "xmlformat",
|
||||
}
|
||||
|
||||
for _, pkg in pairs(mason_reg.get_installed_packages()) do
|
||||
for _, type in pairs(pkg.spec.categories) do
|
||||
-- only act upon a formatter
|
||||
if type == "Formatter" then
|
||||
-- if formatter doesn't have a builtin config, create our own from a generic template
|
||||
if not require("conform").get_formatter_config(pkg.spec.name) then
|
||||
-- the key of the entry to this table
|
||||
-- is the name of the bare executable
|
||||
-- the actual value may not be the absolute path
|
||||
-- in some cases
|
||||
local bin = next(pkg.spec.bin)
|
||||
-- this should be replaced by a function
|
||||
-- that quieries the configured mason install path
|
||||
local prefix = vim.fn.stdpath("data") .. "/mason/bin/"
|
||||
|
||||
formatters[pkg.spec.name] = {
|
||||
command = prefix .. bin,
|
||||
args = { "$FILENAME" },
|
||||
stdin = true,
|
||||
require_cwd = false,
|
||||
}
|
||||
end
|
||||
|
||||
-- finally add the formatter to it's compatible filetype(s)
|
||||
for _, ft in pairs(pkg.spec.languages) do
|
||||
local ftl = string.lower(ft)
|
||||
local ready = mason_reg.get_package(pkg.spec.name):is_installed()
|
||||
if ready then
|
||||
if keymap[ftl] ~= nil then
|
||||
ftl = keymap[ftl]
|
||||
end
|
||||
if name_map[pkg.spec.name] ~= nil then
|
||||
pkg.spec.name = name_map[pkg.spec.name]
|
||||
end
|
||||
formatters_by_ft[ftl] = formatters_by_ft[ftl] or {}
|
||||
table.insert(formatters_by_ft[ftl], pkg.spec.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return {
|
||||
format_on_save = {
|
||||
lsp_fallback = true,
|
||||
timeout_ms = 500,
|
||||
},
|
||||
formatters = formatters,
|
||||
formatters_by_ft = formatters_by_ft,
|
||||
}
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
-- Customize or remove this keymap to your liking
|
||||
"<leader>fm",
|
||||
function()
|
||||
require("conform").format({ async = true })
|
||||
end,
|
||||
mode = "",
|
||||
desc = "Format buffer",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
3
.config/nvim/lua/plugins/mini_icons.lua
Normal file
3
.config/nvim/lua/plugins/mini_icons.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
return {
|
||||
"echasnovski/mini.icons"
|
||||
}
|
||||
6
.config/nvim/lua/plugins/nord.lua
Normal file
6
.config/nvim/lua/plugins/nord.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
return {
|
||||
"shaunsingh/nord.nvim",
|
||||
config = function()
|
||||
vim.cmd[[colorscheme nord]]
|
||||
end,
|
||||
}
|
||||
6
.config/nvim/lua/plugins/statusline.lua
Normal file
6
.config/nvim/lua/plugins/statusline.lua
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
return {
|
||||
"sschleemilch/slimline.nvim",
|
||||
opts = {
|
||||
style = "fg",
|
||||
},
|
||||
}
|
||||
18
.config/nvim/lua/plugins/telescope.lua
Normal file
18
.config/nvim/lua/plugins/telescope.lua
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
return {
|
||||
"nvim-telescope/telescope.nvim",
|
||||
tag = "0.1.8",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
event = "VimEnter",
|
||||
config = function()
|
||||
local builtin = require("telescope.builtin")
|
||||
vim.keymap.set("n", "<leader>sf", builtin.find_files, { desc = "[S]earch [F]iles" })
|
||||
|
||||
vim.keymap.set("n", "<leader>/", function()
|
||||
-- You can pass additional configuration to Telescope to change the theme, layout, etc.
|
||||
builtin.current_buffer_fuzzy_find(require("telescope.themes").get_dropdown({
|
||||
winblend = 20,
|
||||
previewer = false,
|
||||
}))
|
||||
end, { desc = "[/] Fuzzily search in current buffer" })
|
||||
end,
|
||||
}
|
||||
11
.config/nvim/lua/plugins/toggleterm.lua
Normal file
11
.config/nvim/lua/plugins/toggleterm.lua
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
return {
|
||||
"akinsho/toggleterm.nvim",
|
||||
cmd = "ToggleTerm",
|
||||
keys = {
|
||||
{ "<M-\\>", "<cmd>ToggleTerm</cr>", desc = "Toggle Terminal" },
|
||||
},
|
||||
version = "*",
|
||||
opts = {
|
||||
open_mapping = [[<M-\>]],
|
||||
},
|
||||
}
|
||||
14
.config/nvim/lua/plugins/which-key.lua
Normal file
14
.config/nvim/lua/plugins/which-key.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
return {
|
||||
"folke/which-key.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = {},
|
||||
keys = {
|
||||
{
|
||||
"<leader>?",
|
||||
function()
|
||||
require("which-key").show({ global = false })
|
||||
end,
|
||||
desc = "Buffer Local Keymaps (which-key)",
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue