Compare commits

..

5 Commits

Author SHA1 Message Date
7b4ca98038 Add autoformat for rust 2026-01-14 23:29:09 +01:00
08193ed385 Nicer status line 2026-01-14 23:19:19 +01:00
c5d19259e2 Autopairs 2026-01-14 23:13:24 +01:00
08ec842f0d Add file viewer 2026-01-14 23:06:50 +01:00
67e4663479 Add LSP config 2026-01-14 23:05:58 +01:00
5 changed files with 220 additions and 0 deletions

View File

@ -1,8 +1,18 @@
{
"LuaSnip": { "branch": "master", "commit": "3732756842a2f7e0e76a7b0487e9692072857277" },
"catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" },
"cmp-nvim-lsp": { "branch": "main", "commit": "cbc7b02bb99fae35cb42f514762b89b5126651ef" },
"gruvbox.nvim": { "branch": "main", "commit": "a472496e1a4465a2dd574389dcf6cdb29af9bf1b" },
"lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" },
"lualine.nvim": { "branch": "master", "commit": "47f91c416daef12db467145e16bed5bbfe00add8" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "80c0130c5f16b551865a69e832f1feadeedb5fbe" },
"mason.nvim": { "branch": "main", "commit": "44d1e90e1f66e077268191e3ee9d2ac97cc18e65" },
"nvim-autopairs": { "branch": "master", "commit": "c2a0dd0d931d0fb07665e1fedb1ea688da3b80b4" },
"nvim-cmp": { "branch": "main", "commit": "85bbfad83f804f11688d1ab9486b459e699292d6" },
"nvim-lspconfig": { "branch": "master", "commit": "92ee7d42320edfbb81f3cad851314ab197fa324a" },
"nvim-tree.lua": { "branch": "master", "commit": "ca8d82fff26cb12ced239713e3222f4a9dcd0da0" },
"nvim-treesitter": { "branch": "main", "commit": "5a7e5638e7d220575b1c22c8a2e099b52231886e" },
"nvim-web-devicons": { "branch": "master", "commit": "803353450c374192393f5387b6a0176d0972b848" },
"plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" },
"telescope.nvim": { "branch": "master", "commit": "a8c2223ea6b185701090ccb1ebc7f4e41c4c9784" },
"tokyonight.nvim": { "branch": "main", "commit": "5da1b76e64daf4c5d410f06bcb6b9cb640da7dfd" }

View File

@ -19,8 +19,11 @@ vim.opt.rtp:prepend(lazypath)
-- Initialize lazy.nvim
local plugins = {
require("plugins.colorschemes"), -- theme
require("plugins.editing"), -- editing
require("plugins.lsp"), -- LSP
require("plugins.telescope"), -- fuzzy finder
require("plugins.treesitter"), -- syntax tree
require("plugins.ui"), -- UI
}
require("lazy").setup(plugins)

20
lua/plugins/editing.lua Normal file
View File

@ -0,0 +1,20 @@
return {
{
"windwp/nvim-autopairs",
config = function()
local npairs = require("nvim-autopairs")
npairs.setup({
check_ts = true, -- enable Treesitter integration
disable_filetype = { "TelescopePrompt", "vim" },
})
-- If using nvim-cmp for completion, integrate it:
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
local cmp = require("cmp")
cmp.event:on(
"confirm_done",
cmp_autopairs.on_confirm_done()
)
end,
},
}

122
lua/plugins/lsp.lua Normal file
View File

@ -0,0 +1,122 @@
return {
-- LSP installer
{ "williamboman/mason.nvim", config = true },
{ "williamboman/mason-lspconfig.nvim", config = true },
-- LSP configuration
{
"neovim/nvim-lspconfig",
config = function()
-- Initialize Mason
require("mason").setup()
require("mason-lspconfig").setup()
-- Lua for vim
vim.lsp.config("lua_ls", {
settings = {
Lua = {
diagnostics = {
globals = { "vim" }, -- recognize 'vim' as a global
},
workspace = {
library = vim.api.nvim_get_runtime_file("", true), -- includes Neovim runtime files
checkThirdParty = false, -- optional, avoids prompts about unknown libraries
},
telemetry = { enable = false }, -- optional, disable telemetry
},
},
})
vim.lsp.enable("lua_ls")
-- C/C++
vim.lsp.config("clangd", {})
vim.lsp.enable("clangd")
-- Rust
vim.lsp.config("rust_analyzer", {})
vim.lsp.enable("rust_analyzer")
-- Auto format
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = "*.rs",
callback = function()
vim.lsp.buf.format({ async = false })
end,
})
-- Floating diagnostic on hover
vim.api.nvim_create_autocmd("CursorHold", {
callback = function()
vim.diagnostic.open_float(nil, { focusable = false })
end,
})
-- Enable virtual text and signs
vim.diagnostic.config({
virtual_text = false,
signs = true,
underline = true,
update_in_insert = false,
severity_sort = true,
})
-- Optional: add keymaps
local keymap = vim.keymap
keymap.set("n", "gd", vim.lsp.buf.definition, { desc = "Go to definition" })
keymap.set("n", "K", vim.lsp.buf.hover, { desc = "Hover documentation" })
keymap.set("n", "gr", vim.lsp.buf.references, { desc = "References" })
end,
},
-- Completion
{
"hrsh7th/nvim-cmp",
dependencies = {
"hrsh7th/cmp-nvim-lsp",
"L3MON4D3/LuaSnip",
},
config = function()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
}),
})
end,
},
{
"hrsh7th/nvim-cmp",
dependencies = { "hrsh7th/cmp-nvim-lsp", "L3MON4D3/LuaSnip" },
config = function()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item(),
["<C-p>"] = cmp.mapping.select_prev_item(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "buffer" },
}),
})
end,
},
}

65
lua/plugins/ui.lua Normal file
View File

@ -0,0 +1,65 @@
return {
{
"nvim-tree/nvim-tree.lua",
dependencies = { "nvim-tree/nvim-web-devicons" }, -- optional, adds file icons
config = function()
require("nvim-tree").setup({
disable_netrw = true, -- disable netrw (default file explorer)
hijack_netrw = true, -- replace netrw with nvim-tree
open_on_tab = false,
hijack_cursor = false,
update_cwd = true,
diagnostics = {
enable = true,
icons = {
hint = "H",
info = "I",
warning = "W",
error = "E",
},
},
git = {
enable = false,
},
view = {
width = 30,
side = "left",
number = false,
relativenumber = false,
},
})
-- Optional keymap to toggle the tree
vim.keymap.set("n", "<leader>e", "<cmd>NvimTreeToggle<CR>", { desc = "Toggle file explorer" })
end,
},
{
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
config = function()
require("lualine").setup({
options = {
theme = "auto", -- follow your colorscheme
icons_enabled = true,
component_separators = "|",
section_separators = "",
globalstatus = true, -- single statusline
},
sections = {
lualine_a = { "mode" },
lualine_b = { "branch", "diff" },
lualine_c = {
{ "filename", path = 1 }, -- relative path
},
lualine_x = {
"diagnostics",
"encoding",
"filetype",
},
lualine_y = { "progress" },
lualine_z = { "location" },
},
})
end,
},
}