From 6d8dc4e2dee7e99f0b90f907c450c119da9095f1 Mon Sep 17 00:00:00 2001 From: Vishal Raj Date: Mon, 20 Jan 2025 11:59:31 -0800 Subject: [PATCH] adds oil, blame, lazygit, and minimap --- init.lua | 151 ++++++++++++++++++++++----------- lua/custom/plugins/blame.lua | 18 ++++ lua/custom/plugins/dadbod.lua | 5 ++ lua/custom/plugins/lazygit.lua | 21 +++++ lua/custom/plugins/minimap.lua | 77 +++++++++++++++++ lua/custom/plugins/oil.lua | 54 ++++++++++++ 6 files changed, 275 insertions(+), 51 deletions(-) create mode 100644 lua/custom/plugins/blame.lua create mode 100644 lua/custom/plugins/dadbod.lua create mode 100644 lua/custom/plugins/lazygit.lua create mode 100644 lua/custom/plugins/minimap.lua create mode 100644 lua/custom/plugins/oil.lua diff --git a/init.lua b/init.lua index 4ce35f4b..2878169a 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -616,7 +616,10 @@ require('lazy').setup({ local servers = { -- clangd = {}, -- gopls = {}, - -- pyright = {}, + pyright = {}, + ruff = {}, + debugpy = {}, + taplo = {}, -- rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- @@ -709,7 +712,7 @@ require('lazy').setup({ formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'ruff_format', 'isort', 'black', stop_after_first = true }, -- -- You can use 'stop_after_first' to run the first available formatter from the list -- javascript = { "prettierd", "prettier", stop_after_first = true }, @@ -773,24 +776,24 @@ require('lazy').setup({ -- No, but seriously. Please read `:help ins-completion`, it is really good! mapping = cmp.mapping.preset.insert { -- Select the [n]ext item - [''] = cmp.mapping.select_next_item(), + -- [''] = cmp.mapping.select_next_item(), -- Select the [p]revious item - [''] = cmp.mapping.select_prev_item(), + -- [''] = cmp.mapping.select_prev_item(), -- Scroll the documentation window [b]ack / [f]orward - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), + -- [''] = cmp.mapping.scroll_docs(-4), + -- [''] = cmp.mapping.scroll_docs(4), -- Accept ([y]es) the completion. -- This will auto-import if your LSP supports it. -- This will expand snippets if the LSP sent a snippet. - [''] = cmp.mapping.confirm { select = true }, + -- [''] = cmp.mapping.confirm { select = true }, -- If you prefer more traditional completion keymaps, -- you can uncomment the following lines - --[''] = cmp.mapping.confirm { select = true }, - --[''] = cmp.mapping.select_next_item(), - --[''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.confirm { select = true }, + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), -- Manually trigger a completion from nvim-cmp. -- Generally you don't need this, because nvim-cmp will display @@ -829,6 +832,12 @@ require('lazy').setup({ { name = 'luasnip' }, { name = 'path' }, }, + cmp.setup.filetype({ 'sql' }, { + sources = { + { name = 'vim-dadbod-completion' }, + { name = 'buffer' }, + }, + }), } end, }, @@ -838,13 +847,16 @@ require('lazy').setup({ -- change the command in the config to whatever the name of that colorscheme is. -- -- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`. - 'folke/tokyonight.nvim', + -- 'folke/tokyonight.nvim', + 'rose-pine/neovim', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() -- Load the colorscheme here. -- Like many other themes, this one has different styles, and you could load -- any other, such as 'tokyonight-storm', 'tokyonight-moon', or 'tokyonight-day'. - vim.cmd.colorscheme 'tokyonight-night' + -- vim.cmd.colorscheme 'tokyonight-night' + -- vim.cmd.colorscheme 'rose-pine' + vim.cmd.colorscheme 'retrobox' -- You can configure highlights by doing something like: vim.cmd.hi 'Comment gui=none' @@ -854,50 +866,68 @@ require('lazy').setup({ -- Highlight todo, notes, etc in comments { 'folke/todo-comments.nvim', event = 'VimEnter', dependencies = { 'nvim-lua/plenary.nvim' }, opts = { signs = false } }, - { -- Collection of various small independent plugins/modules - 'echasnovski/mini.nvim', - config = function() - -- Better Around/Inside textobjects - -- - -- Examples: - -- - va) - [V]isually select [A]round [)]paren - -- - yinq - [Y]ank [I]nside [N]ext [Q]uote - -- - ci' - [C]hange [I]nside [']quote - require('mini.ai').setup { n_lines = 500 } + -- { -- Collection of various small independent plugins/modules + -- 'echasnovski/mini.nvim', + -- config = function() + -- -- Better Around/Inside textobjects + -- -- + -- -- Examples: + -- -- - va) - [V]isually select [A]round [)]paren + -- -- - yinq - [Y]ank [I]nside [N]ext [Q]uote + -- -- - ci' - [C]hange [I]nside [']quote + -- require('mini.ai').setup { n_lines = 500 } + -- + -- -- Add/delete/replace surroundings (brackets, quotes, etc.) + -- -- + -- -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren + -- -- - sd' - [S]urround [D]elete [']quotes + -- -- - sr)' - [S]urround [R]eplace [)] ['] + -- require('mini.surround').setup() + -- + -- -- Simple and easy statusline. + -- -- You could remove this setup call if you don't like it, + -- -- and try some other statusline plugin + -- local statusline = require 'mini.statusline' + -- -- set use_icons to true if you have a Nerd Font + -- statusline.setup { use_icons = vim.g.have_nerd_font } + -- + -- -- You can configure sections in the statusline by overriding their + -- -- default behavior. For example, here we set the section for + -- -- cursor location to LINE:COLUMN + -- ---@diagnostic disable-next-line: duplicate-set-field + -- statusline.section_location = function() + -- return '%2l:%-2v' + -- end + -- + -- -- ... and there is more! + -- -- Check out: https://github.com/echasnovski/mini.nvim + -- end, + -- }, - -- Add/delete/replace surroundings (brackets, quotes, etc.) - -- - -- - saiw) - [S]urround [A]dd [I]nner [W]ord [)]Paren - -- - sd' - [S]urround [D]elete [']quotes - -- - sr)' - [S]urround [R]eplace [)] ['] - require('mini.surround').setup() - - -- Simple and easy statusline. - -- You could remove this setup call if you don't like it, - -- and try some other statusline plugin - local statusline = require 'mini.statusline' - -- set use_icons to true if you have a Nerd Font - statusline.setup { use_icons = vim.g.have_nerd_font } - - -- You can configure sections in the statusline by overriding their - -- default behavior. For example, here we set the section for - -- cursor location to LINE:COLUMN - ---@diagnostic disable-next-line: duplicate-set-field - statusline.section_location = function() - return '%2l:%-2v' - end - - -- ... and there is more! - -- Check out: https://github.com/echasnovski/mini.nvim - end, - }, { -- Highlight, edit, and navigate code 'nvim-treesitter/nvim-treesitter', build = ':TSUpdate', main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { + 'bash', + 'c', + 'diff', + 'html', + 'lua', + 'luadoc', + 'markdown', + 'markdown_inline', + 'query', + 'vim', + 'vimdoc', + 'python', + 'markdown_inline', + 'markdown', + 'rst', + 'ninja', + }, -- Autoinstall languages that are not installed auto_install = true, highlight = { @@ -937,7 +967,7 @@ require('lazy').setup({ -- This is the easiest way to modularize your config. -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! @@ -965,5 +995,24 @@ require('lazy').setup({ }, }) +-- MiniMap = require 'mini.map' +-- vim.keymap.set('n', 'mt', MiniMap.toggle, { desc = 'Toggle MiniMap' }) +-- vim.keymap.set('n', 'mo', MiniMap.open, { desc = 'Open MiniMap' }) +-- vim.keymap.set('n', 'mc', MiniMap.close, { desc = 'Close MiniMap' }) +-- vim.keymap.set('n', 'mf', MiniMap.toggle_focus, { desc = 'Toggle MiniMap Focus' }) +-- vim.keymap.set('n', 'mr', MiniMap.refresh, { desc = 'Refresh MiniMap' }) +-- vim.keymap.set('n', 'ms', MiniMap.toggle_side, { desc = 'Toggle MiniMap side' }) +-- +vim.api.nvim_create_user_command('LintProject', function() + vim.cmd '!poetry run task lint' +end, {}) + +vim.api.nvim_create_user_command('FormatProject', function() + vim.cmd '!poetry run task format' +end, {}) + +vim.api.nvim_create_user_command('ShowDiagnostic', function() + vim.cmd '!lua vim.diagnostic.open_float()' +end, {}) -- The line beneath this is called `modeline`. See `:help modeline` -- vim: ts=2 sts=2 sw=2 et diff --git a/lua/custom/plugins/blame.lua b/lua/custom/plugins/blame.lua new file mode 100644 index 00000000..2ab9141b --- /dev/null +++ b/lua/custom/plugins/blame.lua @@ -0,0 +1,18 @@ +return { + { + 'FabijanZulj/blame.nvim', + lazy = false, + config = function() + require('blame').setup() + end, + }, + -- keys = { + -- { + -- 'mt', + -- function() + -- vim.keymap.set('n', 'bt', ':BlameToggle') + -- end, + -- desc = 'Toggle git blame window', + -- }, + -- }, +} diff --git a/lua/custom/plugins/dadbod.lua b/lua/custom/plugins/dadbod.lua new file mode 100644 index 00000000..49265212 --- /dev/null +++ b/lua/custom/plugins/dadbod.lua @@ -0,0 +1,5 @@ +return { + 'tpope/vim-dadbod', + 'kristijanhusak/vim-dadbod-completion', + 'kristijanhusak/vim-dadbod-ui', +} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000..fe42cd23 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,21 @@ +-- nvim v0.8.0 +return { + 'kdheepak/lazygit.nvim', + lazy = true, + cmd = { + 'LazyGit', + 'LazyGitConfig', + 'LazyGitCurrentFile', + 'LazyGitFilter', + 'LazyGitFilterCurrentFile', + }, + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + -- setting the keybinding for LazyGit with 'keys' is recommended in + -- order to load the plugin when the command is run for the first time + keys = { + { 'lg', 'LazyGit', desc = 'LazyGit' }, + }, +} diff --git a/lua/custom/plugins/minimap.lua b/lua/custom/plugins/minimap.lua new file mode 100644 index 00000000..df4f7b50 --- /dev/null +++ b/lua/custom/plugins/minimap.lua @@ -0,0 +1,77 @@ +return { + 'echasnovski/mini.map', + version = '*', + -- vim.keymap.set('n', 'mo', MiniMap.open, { desc = 'Open MiniMap' }), + config = function() + -- require('mini.map').setup() + local map = require 'mini.map' + + local diagnostic_integration = map.gen_integration.diagnostic { + error = 'DiagnosticFloatingError', + warn = 'DiagnosticFloatingWarn', + info = 'DiagnosticFloatingInfo', + hint = 'DiagnosticFloatingHint', + } + + local builtin_search_integration = map.gen_integration.builtin_search() + + local gitsigns_integration = map.gen_integration.gitsigns { + add = 'GitSignsAdd', + change = 'GitSignsChange', + delete = 'GitSignsDelete', + } + + map.setup { + integrations = { + diagnostic_integration, + builtin_search_integration, + gitsigns_integration, + }, + } + end, + + keys = { + { + 'mt', + function() + require('mini.map').toggle() + end, + desc = 'Toggle minimap', + }, + { + 'mc', + function() + require('mini.map').close() + end, + desc = 'Close minimap', + }, + { + 'mf', + function() + require('mini.map').toggle_focus() + end, + desc = 'Toggle minimap focus', + }, + { + 'mo', + function() + require('mini.map').open() + end, + desc = 'Open minimap', + }, + { + 'mr', + function() + require('mini.map').refresh() + end, + desc = 'Refresh minimap', + }, + { + 'ms', + function() + require('mini.map').toggle_side() + end, + desc = 'Toggle minimap side', + }, + }, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 00000000..9446ad12 --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,54 @@ +return { + 'stevearc/oil.nvim', + ---@module 'oil' + ---@type oil.SetupOpts + -- to open oil with - as shortcut + vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }), + opts = {}, + -- Optional dependencies + dependencies = { { 'echasnovski/mini.icons', opts = {} } }, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons +} + +-- return { +-- { +-- 'stevearc/oil.nvim', +-- vim.keymap.set('n', '-', 'Oil', { desc = 'Open parent directory' }), +-- dependencies = { "nvim-tree/nvim-web-devicons" }, +-- config = function() +-- CustomOilBar = function() +-- local path = vim.fn.expand "%" +-- path = path:gsub("oil://", "") +-- +-- return " " .. vim.fn.fnamemodify(path, ":.") +-- end +-- +-- require("oil").setup { +-- columns = { "icon" }, +-- keymaps = { +-- [""] = false, +-- [""] = false, +-- [""] = false, +-- [""] = false, +-- [""] = "actions.select_split", +-- }, +-- win_options = { +-- winbar = "%{v:lua.CustomOilBar()}", +-- }, +-- view_options = { +-- show_hidden = true, +-- is_always_hidden = function(name, _) +-- local folder_skip = { "dev-tools.locks", "dune.lock", "_build" } +-- return vim.tbl_contains(folder_skip, name) +-- end, +-- }, +-- } +-- +-- -- Open parent directory in current window +-- vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) +-- +-- -- Open parent directory in floating window +-- vim.keymap.set("n", "-", require("oil").toggle_float) +-- end, +-- }, +-- }