diff --git a/.gitignore b/.gitignore index f484454..7f35012 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ -lua/ pack/ test/ diff --git a/README.md b/README.md index d685dfe..dfed96a 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,16 @@ - I will not seperately complement about the dependecy plugins of these pluginsn as I do not have a direct interactions with them. - But I believe that as they are a hard dependency so they must be doing something very vital for them. -## nvim-tree +## nvim-tree.lua - url: https://github.com/nvim-tree/nvim-tree.lua +- This has been a very useful addition to my whole plugin ecosysystem. +- I use a floating nvim-tree, this helps me in saving space from having a permananent setting. + +## telescope + + # Directory Structure ``` @@ -34,6 +40,7 @@ │   ├── mini.icons │   ├── nvim-cmp │   ├── nvim-lspconfig +│   ├── nvim-tree.lua │   ├── plenary.nvim │   └── telescope.nvim └── test diff --git a/init.lua b/init.lua index b084581..23f15cb 100644 --- a/init.lua +++ b/init.lua @@ -7,6 +7,8 @@ vim.opt.shiftwidth = 2 -- Indent width vim.opt.expandtab = true -- Use spaces instead of tabs vim.opt.wrap = true +--vim.cmd.colorscheme("retrobox") +vim.opt.termguicolors = true vim.opt.clipboard = 'unnamedplus' -- System clipboard @@ -16,149 +18,6 @@ vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" }) vim.api.nvim_set_hl(0, "EndOfBuffer", { bg = "none" }) -require("nvim-tree").setup({ - view = { - float = { - enable = true, - open_win_config = function() - local screen_w = vim.opt.columns:get() - local screen_h = vim.opt.lines:get() - - local window_w = math.floor(screen_w * 0.6) - local window_h = math.floor(screen_h * 0.7) - - local center_x = math.floor((screen_w - window_w) / 2) - local center_y = math.floor((screen_h - window_h) / 2) - - return { - border = "rounded", - relative = "editor", - row = center_y, - col = center_x, - width = window_w, - height = window_h, - } - end, - }, - width = 30, - }, - - actions = { - open_file = { - quit_on_open = true, -- closes tree when opening a file - }, - }, - - renderer = { - highlight_git = true, - icons = { - show = { - git = true, - folder = true, - file = true, - folder_arrow = true, - }, - }, - }, -}) - - - --- require("nvim-tree").setup({ --- view = { --- side = "left", - -- This is the key setting for sharing across tabs --- }, --- actions = { --- open_file = { --- quit_on_open = false, - -- Prevent nvim-tree from closing when opening a file --- }, --- }, --- hijack_directories = { --- enable = false, --- }, --- sync_root_with_cwd = true, --- respect_buf_cwd = true, --- update_focused_file = { --- enable = true, --- update_root = false, --- }, --- }) - -vim.diagnostic.config({ - severity_sort = true, - virtual_text = true, -}) - -local cmp = require('cmp') -cmp.setup({ - sources = { - { name = 'nvim_lsp' }, - }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.confirm({ select = true }), - }), -}) - -require('lspconfig').pyright.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), -}) - -require('lspconfig').lua_ls.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), - settings = { - Lua = { - diagnostics = { - globals = { 'vim' } - } - } - } -}) - -require('lspconfig').rust_analyzer.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), -}) - ---Enable (broadcasting) snippet capability for completion -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities.textDocument.completion.completionItem.snippetSupport = true - -require'lspconfig'.html.setup { - capabilities = capabilities, -} - -require('lspconfig').gopls.setup({ - capabilities = require('cmp_nvim_lsp').default_capabilities(), - settings = { - gopls = { - analyses = { - unusedparams = true, - nilness = true, - unusedwrite = true, - useany = true, - }, - staticcheck = true, - gofumpt = true, - }, - }, -}) - - -vim.keymap.set("n", "gd", vim.lsp.buf.definition) -vim.keymap.set("n", "gD", vim.lsp.buf.declaration) -vim.keymap.set("n", "gr", vim.lsp.buf.references) -vim.keymap.set("n", "K", vim.lsp.buf.hover) - - -local builtin = require('telescope.builtin') -vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) -vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) -vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) -vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) - - -- Git signs require('gitsigns').setup() @@ -167,3 +26,35 @@ require('flash').setup() vim.keymap.set({"n","x","o"}, "s", function() require("flash").jump() end) + + +require("nvim-treesitter").setup({ + ensure_installed = { + "lua", + "python", + "c", + "cpp", + "go", + "bash", + "json", + "yaml", + "html", + "css", + "javascript", + "markdown", + "markdown_inline" + }, + + auto_install = true, + + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + + indent = { + enable = true, + }, +}) + +require("rakshit") diff --git a/lua/rakshit/init.lua b/lua/rakshit/init.lua new file mode 100644 index 0000000..f731482 --- /dev/null +++ b/lua/rakshit/init.lua @@ -0,0 +1,2 @@ +require("rakshit.plugins") +require("rakshit.lsp") diff --git a/lua/rakshit/lsp/init.lua b/lua/rakshit/lsp/init.lua new file mode 100644 index 0000000..393a924 --- /dev/null +++ b/lua/rakshit/lsp/init.lua @@ -0,0 +1 @@ +require("rakshit.lsp.main") diff --git a/lua/rakshit/lsp/main.lua b/lua/rakshit/lsp/main.lua new file mode 100644 index 0000000..40f7eae --- /dev/null +++ b/lua/rakshit/lsp/main.lua @@ -0,0 +1,74 @@ +-- diagnostics +vim.diagnostic.config({ + severity_sort = true, + virtual_text = true, +}) + +-- cmp setup +local cmp = require('cmp') +cmp.setup({ + sources = { + { name = 'nvim_lsp' }, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.confirm({ select = true }), + }), +}) + +-- shared capabilities (cmp + snippet support) +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 + + 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') + +local function setup(server, opts) + opts = opts or {} + opts.capabilities = capabilities + opts.on_attach = on_attach + lspconfig[server].setup(opts) +end + +-- servers +setup("pyright") +setup("rust_analyzer") + +setup("lua_ls", { + settings = { + Lua = { + diagnostics = { + globals = { "vim" } + } + } + } +}) + +setup("html") + +setup("gopls", { + settings = { + gopls = { + analyses = { + unusedparams = true, + nilness = true, + unusedwrite = true, + useany = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, +}) diff --git a/lua/rakshit/plugins/filefinder.lua b/lua/rakshit/plugins/filefinder.lua new file mode 100644 index 0000000..af04d31 --- /dev/null +++ b/lua/rakshit/plugins/filefinder.lua @@ -0,0 +1,5 @@ +local builtin = require('telescope.builtin') +vim.keymap.set('n', 'ff', builtin.find_files, { desc = 'Telescope find files' }) +vim.keymap.set('n', 'fg', builtin.live_grep, { desc = 'Telescope live grep' }) +vim.keymap.set('n', 'fb', builtin.buffers, { desc = 'Telescope buffers' }) +vim.keymap.set('n', 'fh', builtin.help_tags, { desc = 'Telescope help tags' }) diff --git a/lua/rakshit/plugins/filemanager.lua b/lua/rakshit/plugins/filemanager.lua new file mode 100644 index 0000000..399defc --- /dev/null +++ b/lua/rakshit/plugins/filemanager.lua @@ -0,0 +1,45 @@ +require("nvim-tree").setup({ + view = { + float = { + enable = true, + open_win_config = function() + local screen_w = vim.opt.columns:get() + local screen_h = vim.opt.lines:get() + + local window_w = math.floor(screen_w * 0.6) + local window_h = math.floor(screen_h * 0.7) + + local center_x = math.floor((screen_w - window_w) / 2) + local center_y = math.floor((screen_h - window_h) / 2) + + return { + border = "rounded", + relative = "editor", + row = center_y, + col = center_x, + width = window_w, + height = window_h, + } + end, + }, + width = 30, + }, + + actions = { + open_file = { + quit_on_open = true, -- closes tree when opening a file + }, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + folder = true, + file = true, + folder_arrow = true, + }, + }, + }, +}) diff --git a/lua/rakshit/plugins/init.lua b/lua/rakshit/plugins/init.lua new file mode 100644 index 0000000..cb1c2a4 --- /dev/null +++ b/lua/rakshit/plugins/init.lua @@ -0,0 +1,2 @@ +require("rakshit.plugins.filemanager") +require("rakshit.plugins.filefinder")