Added initial nvim config
This commit is contained in:
parent
aca7a8c3bb
commit
5d0ed8da19
15 changed files with 282 additions and 0 deletions
1
.config/nvim/init.lua
Normal file
1
.config/nvim/init.lua
Normal file
|
|
@ -0,0 +1 @@
|
|||
require("config")
|
||||
16
.config/nvim/lazy-lock.json
Normal file
16
.config/nvim/lazy-lock.json
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"conform.nvim": { "branch": "master", "commit": "70019124aa4f2e6838be9fbd2007f6d13b27a96d" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "5f808b5e4fef30bd8aca1b803b4e555da07fc412" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "259357fa4097e232730341fa60988087d189193a" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "7e6c863bc7563efbdd757a310d17ebc95166cef3" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "c6c686781f9841d855bf1b926e10aa5e19430a38" },
|
||||
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
|
||||
"mini.icons": { "branch": "main", "commit": "6787321f70d674a481776b7cc2c781fb7002c644" },
|
||||
"nord.nvim": { "branch": "master", "commit": "80c1e5321505aeb22b7a9f23eb82f1e193c12470" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "a8ef5e6e497b3ebeaaf35b939c07c211563b2e05" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
|
||||
"slimline.nvim": { "branch": "main", "commit": "5a7e91619496c4655e02e7ba26aae6b9a5b5a564" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" },
|
||||
"toggleterm.nvim": { "branch": "main", "commit": "50ea089fc548917cc3cc16b46a8211833b9e3c7c" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "8ab96b38a2530eacba5be717f52e04601eb59326" }
|
||||
}
|
||||
3
.config/nvim/lua/config/init.lua
Normal file
3
.config/nvim/lua/config/init.lua
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
require('config.lazy')
|
||||
require('config.settings')
|
||||
require('config.keybinds')
|
||||
5
.config/nvim/lua/config/keybinds.lua
Normal file
5
.config/nvim/lua/config/keybinds.lua
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- Remap Ctrl + h/j/k/l for pane movement
|
||||
vim.api.nvim_set_keymap('n', '<C-h>', '<C-w>h', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-j>', '<C-w>j', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-k>', '<C-w>k', { noremap = true, silent = true })
|
||||
vim.api.nvim_set_keymap('n', '<C-l>', '<C-w>l', { noremap = true, silent = true })
|
||||
35
.config/nvim/lua/config/lazy.lua
Normal file
35
.config/nvim/lua/config/lazy.lua
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
-- Bootstrap lazy.nvim
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not (vim.uv or vim.loop).fs_stat(lazypath) then
|
||||
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
|
||||
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
|
||||
if vim.v.shell_error ~= 0 then
|
||||
vim.api.nvim_echo({
|
||||
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
|
||||
{ out, "WarningMsg" },
|
||||
{ "\nPress any key to exit..." },
|
||||
}, true, {})
|
||||
vim.fn.getchar()
|
||||
os.exit(1)
|
||||
end
|
||||
end
|
||||
vim.opt.rtp:prepend(lazypath)
|
||||
|
||||
-- Make sure to setup `mapleader` and `maplocalleader` before
|
||||
-- loading lazy.nvim so that mappings are correct.
|
||||
-- This is also a good place to setup other settings (vim.opt)
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = "\\"
|
||||
|
||||
-- Setup lazy.nvim
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- import your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
-- Configure any other settings here. See the documentation for more details.
|
||||
-- colorscheme that will be used when installing plugins.
|
||||
install = { colorscheme = { "nord" } },
|
||||
-- automatically check for plugin updates
|
||||
checker = { enabled = true },
|
||||
})
|
||||
29
.config/nvim/lua/config/settings.lua
Normal file
29
.config/nvim/lua/config/settings.lua
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
-- Line numbers
|
||||
vim.wo.number = true
|
||||
|
||||
-- Tabs
|
||||
vim.o.expandtab = true
|
||||
vim.o.smartindent = true
|
||||
vim.o.tabstop = 4
|
||||
vim.o.shiftwidth = 4
|
||||
|
||||
-- Clipboard
|
||||
vim.o.clipboard = "unnamedplus"
|
||||
|
||||
-- Restore cursor
|
||||
local restore_cursor_augroup = vim.api.nvim_create_augroup("restore_cursor_shape_on_exit", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "VimLeave" }, {
|
||||
group = restore_cursor_augroup,
|
||||
desc = "restore the cursor shape on exit of neovim",
|
||||
command = "set guicursor=a:ver20",
|
||||
})
|
||||
|
||||
-- Horizontal Split Line
|
||||
vim.opt.laststatus = 3
|
||||
|
||||
-- Padding around current line
|
||||
vim.opt.scrolloff = 5
|
||||
|
||||
-- Highlight current line
|
||||
vim.opt.cursorline = true
|
||||
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