Added nvim config

This commit is contained in:
JirR02 2023-11-22 15:57:19 +01:00
parent bb149aea3a
commit fce1a21447
24 changed files with 556 additions and 0 deletions

4
.config/nvim/init.lua Normal file
View File

@ -0,0 +1,4 @@
require("jirr02.core.options")
require("jirr02.core.keymaps")
require("jirr02.core.colorscheme")
require("jirr02.lazy")

View File

@ -0,0 +1,42 @@
{
"LuaSnip": { "branch": "master", "commit": "a4de64570b9620875c8ea04175cd07ed8e32ac99" },
"ReplaceWithRegister": { "branch": "master", "commit": "832efc23111d19591d495dc72286de2fb0b09345" },
"alpha-nvim": { "branch": "main", "commit": "234822140b265ec4ba3203e3e0be0e0bb826dff5" },
"bufferline.nvim": { "branch": "main", "commit": "9e8d2f695dd50ab6821a6a53a840c32d2067a78a" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"comment.nvim": { "branch": "master", "commit": "0236521ea582747b58869cb72f70ccfa967d2e89" },
"dracula.nvim": { "branch": "main", "commit": "7200e64c589f899d29f8963aad7543856d1c2545" },
"friendly-snippets": { "branch": "main", "commit": "43727c2ff84240e55d4069ec3e6158d74cb534b6" },
"gitsigns.nvim": { "branch": "main", "commit": "af0f583cd35286dd6f0e3ed52622728703237e50" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lspkind.nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "40301e1c74bc0946eece13edf2b1c561cc497491" },
"mason-null-ls.nvim": { "branch": "main", "commit": "ae0c5fa57468ac65617f1bf821ba0c3a1e251f0c" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "e4f34741daa9cf95de68a603d3e7a6844a69fdf0" },
"mason.nvim": { "branch": "main", "commit": "eabf6d347fdb75be360d4c0ced1145670a171453" },
"noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" },
"none-ls.nvim": { "branch": "main", "commit": "b8fd44ee1616e6a9c995ed5f94ad9f1721d303ef" },
"nui.nvim": { "branch": "main", "commit": "c0c8e347ceac53030f5c1ece1c5a5b6a17a25b32" },
"nvim-autopairs": { "branch": "master", "commit": "0f04d78619cce9a5af4f355968040f7d675854a1" },
"nvim-bufdel": { "branch": "main", "commit": "96c4f7ab053ddab0025bebe5f7c71e4795430e47" },
"nvim-cmp": { "branch": "main", "commit": "51260c02a8ffded8e16162dcf41a23ec90cfba62" },
"nvim-lint": { "branch": "master", "commit": "7746f952827dabfb70194518c99c93d5651b8f19" },
"nvim-lspconfig": { "branch": "master", "commit": "b44737605807023d32e6310b87ba69f4dbf10e0e" },
"nvim-notify": { "branch": "master", "commit": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3" },
"nvim-surround": { "branch": "main", "commit": "4f0e1f470595af067eca9b872778d83c7f52f134" },
"nvim-tree.lua": { "branch": "master", "commit": "7e3c0bee7b246ca835d5f7453db6fa19de359bab" },
"nvim-treesitter": { "branch": "master", "commit": "a82bba45fb0fb43fc2e7998f3394fadc80606d8a" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "e69a504baf2951d52e1f1fbb05145d43f236cbf1" },
"nvim-web-devicons": { "branch": "master", "commit": "5de460ca7595806044eced31e3c36c159a493857" },
"plenary.nvim": { "branch": "master", "commit": "50012918b2fc8357b87cff2a7f7f0446e47da174" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
"telescope.nvim": { "branch": "master", "commit": "4522d7e3ea75ffddabdc39957168a8a7060b5df0" },
"vim-fugitive": { "branch": "master", "commit": "46eaf8918b347906789df296143117774e827616" },
"vim-surround": { "branch": "master", "commit": "3d188ed2113431cf8dac77be61b842acb64433d9" },
"vim-tmux-navigator": { "branch": "master", "commit": "7db70e08ea03b3e4d91f63713d76134512e28d7e" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }
}

View File

@ -0,0 +1,6 @@
return {
"Mofiqul/dracula.nvim",
config = function()
vim.cmd([[colorscheme dracula]])
end,
}

View File

@ -0,0 +1,8 @@
vim.g.mapleader = " "
local keymap = vim.keymap
keymap.set("i", "jk", "<ESC>", { desc = "Exit out of insert mode" })
keymap.set("n", "<leader>q", "<cmd>wq<CR>", { desc = "Exit NeoVim and Save file" })
keymap.set("n", "<leader>w", "<cmd>w<CR>", { desc = "Save file" })
keymap.set("n", "<leader>-", "gcc", { desc = "Toggle comment" })

View File

@ -0,0 +1,25 @@
local opt = vim.opt
opt.relativenumber = true
opt.number = true
opt.tabstop = 2
opt.shiftwidth = 2
opt.expandtab = true
opt.autoindent = true
opt.ignorecase = true
opt.smartcase = true
opt.termguicolors = true
opt.background = "dark"
opt.signcolumn = "yes"
opt.backspace = "indent,eol,start"
opt.clipboard:append("unnamedplus")
opt.splitright = true
opt.splitbelow = true
opt.iskeyword:append("-")

View File

@ -0,0 +1,14 @@
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
require("lazy").setup({ { import = "jirr02.plugins" }, { import = "jirr02.core.colorscheme" }, { import = "jirr02.plugins.lsp"} })

View File

@ -0,0 +1,24 @@
return {
"goolord/alpha-nvim",
event = "VimEnter",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local alpha = require("alpha")
local dashboard = require("alpha.themes.dashboard")
-- Set menu
dashboard.section.buttons.val = {
dashboard.button("e", " > New File", "<cmd>ene<CR>"),
dashboard.button("SPC ee", " > Toggle file explorer", "<cmd>NvimTreeToggle<CR>"),
dashboard.button("SPC ff", "󰱼 > Find File", "<cmd>Telescope find_files<CR>"),
dashboard.button("SPC fs", " > Find Word", "<cmd>Telescope live_grep<CR>"),
dashboard.button("q", " > Quit NVIM", "<cmd>qa<CR>"),
}
-- Send config to alpha
alpha.setup(dashboard.opts)
-- Disable folding on alpha buffer
vim.cmd([[autocmd FileType alpha setlocal nofoldenable]])
end,
}

View File

@ -0,0 +1,9 @@
return {
"windwp/nvim-autopairs",
config = function()
local autopairs = require("nvim-autopairs")
autopairs.setup()
end
}

View File

@ -0,0 +1,27 @@
return {
"akinsho/bufferline.nvim",
dependencies = {
"nvim-tree/nvim-web-devicons",
"ojroques/nvim-bufdel",
},
config = function()
local bufferline = require("bufferline")
local wk = require("which-key")
bufferline.setup({
options = {
mode = "buffers",
seperator_style = "slant",
},
})
wk.register({
b = {
name = "buffer",
x = { "<cmd>BufDel<CR>", "Close Buffer" },
n = { "<cmd>BufferLineCycleNext<CR>", "Go to next buffer" },
p = { "<cmd>BufferLineCyclePrev<CR>", "Go to previous buffer" },
},
}, { prefix = "<leader>" })
end,
}

View File

@ -0,0 +1,8 @@
return {
"numToStr/comment.nvim",
config = function()
local comment = require("Comment")
comment.setup({})
end,
}

View File

@ -0,0 +1,4 @@
return {
"lewis6991/gitsigns.nvim",
config = true,
}

View File

@ -0,0 +1,7 @@
return {
{ "tpope/vim-surround" },
{ "vim-scripts/ReplaceWithRegister" },
{ "mfussenegger/nvim-lint" },
{ "christoomey/vim-tmux-navigator" },
{ "tpope/vim-fugitive" },
}

View File

@ -0,0 +1,60 @@
return {
"neovim/nvim-lspconfig",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"onsails/lspkind.nvim",
},
config = function()
local lspconfig = require("lspconfig")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local wk = require("which-key")
local capabilities = cmp_nvim_lsp.default_capabilities()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
settings = { -- custom settings for lua
Lua = {
-- make the language server recognize "vim" global
diagnostics = {
globals = { "vim" },
},
workspace = {
-- make language server aware of runtime files
library = {
[vim.fn.expand("$VIMRUNTIME/lua")] = true,
[vim.fn.stdpath("config") .. "/lua"] = true,
},
},
},
},
})
lspconfig["pyright"].setup({
capabilities = capabilities,
filetypes = { "python" },
})
lspconfig["clangd"].setup({
capabilities = capabilities,
})
lspconfig["marksman"].setup({
capabilities = capabilities,
})
lspconfig["texlab"].setup({
capabilities = capabilities,
})
wk.register({
l = {
name = "lsp",
r = { "<cmd>Telescope lsp_references<CR>", "Show references" },
D = { "<cmd>lua vim.lsp.buf.defenition()<CR>", "Show defenition" },
c = { "<cmd>lua vim.lsp.buf.code_action()<CR>", "Code actions" },
R = { "<cmd>lua vim.lsp.buf.rename()<CR>", "Smart rename" },
d = { "<cmd>Telescope diagnostics bufnr=0<CR>", "Diagnostics" },
l = { "<cmd>lua vim.lsp.buf.open_float()<CR>", "Line Diagnostics" },
n = { "<cmd>lua vim.diagnostics.goto_next()<CR>", "Go to next Diagnostic" },
p = { "<cmd>lua vim.diagnostics.goto_prev()<CR>", "Go to previous Diagnostic" },
i = { "<cmd>lua vim.lsp.buf.hover()<CR>", "Show documentation" },
L = { "<cmd>LspRestart<CR>", "Restart LSP" },
},
}, { prefix = "<leader>" })
end,
}

View File

@ -0,0 +1,37 @@
return {
"williamboman/mason.nvim",
dependencies = {
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
},
config = function()
local mason = require("mason")
local mason_lspconfig = require("mason-lspconfig")
local mason_tool_installer = require("mason-tool-installer")
mason.setup()
mason_lspconfig.setup({
ensure_installed = {
"lua_ls",
"pyright",
"clangd",
"marksman",
"texlab",
},
})
mason_tool_installer.setup({
ensure_installed = {
"mypy",
"ruff",
"black",
"clang-format",
"stylua",
"prettier",
"vale",
"latexindent",
},
})
end,
}

View File

@ -0,0 +1,52 @@
return {
"nvimtools/none-ls.nvim",
dependencies = {
"jay-babu/mason-null-ls.nvim",
},
config = function()
local mason_null_ls = require("mason-null-ls")
local null_ls = require("null-ls")
local augroup = vim.api.nvim_create_augroup("LspFormatting", {})
local formatting = null_ls.builtins.formatting
local diagnostics = null_ls.builtins.diagnostics
mason_null_ls.setup()
null_ls.setup({
debug = true,
sources = {
formatting.stylua,
formatting.black,
formatting.clang_format,
formatting.prettier,
formatting.latexindent,
diagnostics.mypy.with({
extra_args = function()
local virtual = os.getenv("VIRTUAL_ENV") or os.getenv("CONDA_PREFIX") or "/usr"
return { "--python-executable", virtual .. "/bin/python3" }
end,
}),
diagnostics.ruff,
diagnostics.vale,
},
on_attach = function(current_client, bufnr)
if current_client.supports_method("textDocument/formatting") then
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
buffer = bufnr,
callback = function()
vim.lsp.buf.format({
filter = function(client)
-- only use null-ls for formatting instead of lsp server
return client.name == "null-ls"
end,
bufnr = bufnr,
})
end,
})
end
end,
})
end,
}

View File

@ -0,0 +1,13 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local lualine = require("lualine")
lualine.setup({
options = {
theme = 'dracula-nvim',
},
})
end
}

View File

@ -0,0 +1,12 @@
return {
"folke/noice.nvim",
dependencies = {
"MunifTanjim/nui.nvim",
"rcarriga/nvim-notify",
},
config = function()
local noice = require("noice")
noice.setup()
end,
}

View File

@ -0,0 +1,51 @@
return {
"hrsh7th/nvim-cmp",
event = "InsertEnter",
dependencies = {
"hrsh7th/cmp-buffer",
"hrsh7th/cmp-path",
"L3MON4D3/LuaSnip",
"saadparwaiz1/cmp_luasnip",
"rafamadriz/friendly-snippets",
"onsails/lspkind.nvim",
},
config = function()
local cmp = require("cmp")
local luasnip = require("luasnip")
local lspkind = require("lspkind")
require("luasnip.loaders.from_vscode").lazy_load()
cmp.setup({
completion = {
completeopt = "menu,menuone,preview,noselect",
},
snippet = { -- configure how nvim-cmp interacts with snippet engine
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-k>"] = cmp.mapping.select_prev_item(), -- previous suggestion
["<C-j>"] = cmp.mapping.select_next_item(), -- next suggestion
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), -- show completion suggestions
["<C-e>"] = cmp.mapping.abort(), -- close completion window
["<CR>"] = cmp.mapping.confirm({ select = false }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" }, -- snippets
{ name = "buffer" }, -- text within current buffer
{ name = "path" }, -- file system paths
}),
formatting = {
format = lspkind.cmp_format({
maxwidth = 50,
ellipsis_char = "...",
}),
},
})
end,
}

View File

@ -0,0 +1,4 @@
return {
"kylechui/nvim-surround",
config = true,
}

View File

@ -0,0 +1,51 @@
return {
"nvim-tree/nvim-tree.lua",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
local nvimtree = require("nvim-tree")
local wk = require("which-key")
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1
nvimtree.setup({
view = {
width = 35,
relativenumber = true,
},
renderer = {
indent_markers = {
enable = true,
},
icons = {
glyphs = {
folder = {
arrow_closed = "", -- arrow when folder is closed
arrow_open = "", -- arrow when folder is open
},
},
},
},
actions = {
open_file = {
window_picker = {
enable = false,
},
},
},
filters = {
custom = { ".DS_Store" },
},
git = {
ignore = false,
},
})
wk.register({
e = {
name = "explorer",
e = { "<cmd>NvimTreeToggle<CR>", "Toggle File Explorer" },
r = { "<cmd>NvimTreeRefresh<CR>", "Refresh File Explorer" },
},
}, { prefix = "<leader>" })
end,
}

View File

@ -0,0 +1,25 @@
return {
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
"nvim-tree/nvim-web-devicons",
},
config = function()
local telescope = require("telescope")
local wk = require("which-key")
telescope.load_extension("fzf")
wk.register({
f = {
name = "file",
f = { "<cmd>Telescope find_files<CR>", "Find Files in Current Working Directory" },
r = { "<cmd>Telescope oldfiles<CR>", "Recent Files" },
s = { "<cmd>Telescope grep_string<CR>", "Find String in File" },
g = { "<cmd>Telescope git_files<CR>", "Find git files" },
},
}, { prefix = "<leader>" })
end,
}

View File

@ -0,0 +1,14 @@
return {
"nvim-treesitter/nvim-treesitter-textobjects",
lazy = true,
config = function()
require("nvim-treesitter.configs").setup({
textobjects = {
select = {
enable = true,
lookahead = true,
},
},
})
end,
}

View File

@ -0,0 +1,11 @@
return {
"nvim-treesitter/nvim-treesitter",
dependencies = {
"nvim-treesitter/nvim-treesitter-textobjects",
},
config = function()
local treesitter = require("nvim-treesitter.configs")
treesitter.setup({})
end,
}

View File

@ -0,0 +1,48 @@
return {
"folke/which-key.nvim",
event = "VeryLazy",
init = function()
vim.o.timeout = true
vim.o.timeoutlen = 500
end,
config = function()
local wk = require("which-key")
wk.setup({
opts = {},
})
wk.register({
n = {
name = "vim",
h = { "<cmd>nohl<CR>", "Close Search Highlights" },
},
s = {
name = "splits",
v = { "<C-w>v", "Split vertical" },
s = { "<C-w>s", "Split horizontal" },
e = { "<C-w>=", "Make Splits equal" },
x = { "<cmd>close<CR>", "Close Split" },
},
m = {
name = "menu",
l = { "<cmd>Lazy<CR>", "Open Lazy Menu" },
m = { "<cmd>Mason<CR>", "Open Mason Menu" },
},
g = {
name = "git",
t = { "<cmd>Gitsigns toggle_signs<CR>", "Toggle Gitsigns" },
h = { "<cmd>Gitsigns toggle_linehl<CR>", "Toggle Line Highlights" },
s = { "<cmd>Telescope git_status<CR>", "git status" },
d = { "<cmd>Gvdiff<CR>", "Differences" },
w = { "<cmd>Gwrite<CR>", "Add File" },
N = { "<cmd>Gitsigns next_hunk<CR>", "Go to next hunk" },
P = { "<cmd>Gitsigns prev_hunk<CR>", "Go to previous hunk" },
c = { "<cmd>Git commit<CR>", "Commit" },
H = { "<cmd>Gitsigns stage_hunk", "Stage hunk" },
p = { "<cmd>Git push<CR>", "Push" },
C = { "<cmd>Telescope git_commits<CR>", "View commits" },
b = { "<cmd>Telescope git_branches<CR>", "View branches" },
},
}, { prefix = "<leader>" })
end,
}