From 80b614a0f3f4bb695486c78aedc415ff96b6a7ba Mon Sep 17 00:00:00 2001 From: Rakshit Kumar Singh Date: Thu, 2 Apr 2026 06:08:25 +0530 Subject: [PATCH] deprication, hide dot files and undotree --- init.lua | 14 ++------ lua/rakshit/lsp/main.lua | 52 ++++++++++++++--------------- lua/rakshit/plugins/filemanager.lua | 4 +++ lua/rakshit/plugins/unused.lua | 12 +++++++ 4 files changed, 45 insertions(+), 37 deletions(-) create mode 100644 lua/rakshit/plugins/unused.lua diff --git a/init.lua b/init.lua index 4edbfb6..12772f6 100644 --- a/init.lua +++ b/init.lua @@ -7,7 +7,7 @@ vim.opt.shiftwidth = 2 -- Indent width vim.opt.expandtab = true -- Use spaces instead of tabs vim.opt.wrap = true ---vim.cmd.colorscheme("retrobox") +vim.cmd.colorscheme("retrobox") vim.opt.termguicolors = true vim.opt.clipboard = 'unnamedplus' -- System clipboard @@ -59,13 +59,5 @@ require("nvim-treesitter").setup({ require("rakshit") -function _G.my_statusline() - local w = vim.api.nvim_win_get_width(0) - if w > 140 then - return "%F %y %m %= %l:%c %p%%" - else - return "%f %= %l:%c" - end -end - -vim.o.statusline = "%!v:lua.my_statusline()" +vim.cmd("packadd nvim.undotree") +vim.keymap.set("n", "u", require("undotree").open) diff --git a/lua/rakshit/lsp/main.lua b/lua/rakshit/lsp/main.lua index 73a7648..0313cb2 100644 --- a/lua/rakshit/lsp/main.lua +++ b/lua/rakshit/lsp/main.lua @@ -21,32 +21,29 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true -- shared keymaps when LSP attaches -local on_attach = function(_, bufnr) - local map = function(mode, lhs, rhs) - vim.keymap.set(mode, lhs, rhs, { buffer = bufnr }) - end +vim.api.nvim_create_autocmd('LspAttach', { + callback = function(args) + local map = function(mode, lhs, rhs) + vim.keymap.set(mode, lhs, rhs, { buffer = args.buf }) + end - map("n", "gd", vim.lsp.buf.definition) - map("n", "gD", vim.lsp.buf.declaration) - map("n", "gr", vim.lsp.buf.references) - map("n", "K", vim.lsp.buf.hover) -end + map("n", "gd", vim.lsp.buf.definition) + map("n", "gD", vim.lsp.buf.declaration) + map("n", "gr", vim.lsp.buf.references) + map("n", "K", vim.lsp.buf.hover) + end, +}) --- helper to setup servers -local lspconfig = require('lspconfig') +-- shared config applied to all servers +vim.lsp.config('*', { + capabilities = capabilities, +}) -local function setup(server, opts) - opts = opts or {} - opts.capabilities = capabilities - opts.on_attach = on_attach - lspconfig[server].setup(opts) -end +-- per-server config +vim.lsp.config('pyright', {}) +vim.lsp.config('rust_analyzer', {}) --- servers -setup("pyright") -setup("rust_analyzer") - -setup("lua_ls", { +vim.lsp.config('lua_ls', { settings = { Lua = { diagnostics = { @@ -56,9 +53,9 @@ setup("lua_ls", { } }) -setup("html") +vim.lsp.config('html', {}) -setup("gopls", { +vim.lsp.config('gopls', { settings = { gopls = { analyses = { @@ -73,6 +70,9 @@ setup("gopls", { }, }) -setup("clangd", { - cmd = { "clangd", "--background-index", "--query-driver=/usr/bin/gcc,/usr/bin/g++",}, +vim.lsp.config('clangd', { + cmd = { "clangd", "--background-index", "--query-driver=/usr/bin/gcc,/usr/bin/g++"}, }) + +-- enable all configured servers +vim.lsp.enable({ 'pyright', 'rust_analyzer', 'lua_ls', 'html', 'gopls', 'clangd' }) diff --git a/lua/rakshit/plugins/filemanager.lua b/lua/rakshit/plugins/filemanager.lua index 399defc..33bf771 100644 --- a/lua/rakshit/plugins/filemanager.lua +++ b/lua/rakshit/plugins/filemanager.lua @@ -42,4 +42,8 @@ require("nvim-tree").setup({ }, }, }, + + filters = { + dotfiles = true, + }, }) diff --git a/lua/rakshit/plugins/unused.lua b/lua/rakshit/plugins/unused.lua new file mode 100644 index 0000000..55d3b8f --- /dev/null +++ b/lua/rakshit/plugins/unused.lua @@ -0,0 +1,12 @@ +function _G.my_statusline() + local w = vim.api.nvim_win_get_width(0) + if w > 140 then + return "%F %y %m %= %l:%c %p%%" + else + return "%f %= %l:%c" + end +end + +vim.o.statusline = "%!v:lua.my_statusline()" + +