diff --git a/init.lua b/init.lua index 13c8143d..1619f6d8 100644 --- a/init.lua +++ b/init.lua @@ -157,6 +157,13 @@ vim.opt.cursorline = true -- Minimal number of screen lines to keep above and below the cursor. vim.opt.scrolloff = 10 +vim.opt.tabstop = 4 + +vim.opt.shiftwidth = 4 + +vim.opt.expandtab = true + +vim.opt.list = false -- [[ Basic Keymaps ]] -- See `:help vim.keymap.set()` @@ -190,6 +197,8 @@ vim.keymap.set('n', '', '', { desc = 'Move focus to the right win vim.keymap.set('n', '', '', { desc = 'Move focus to the lower window' }) vim.keymap.set('n', '', '', { desc = 'Move focus to the upper window' }) +vim.keymap.set('n', '', 'Neotree toggle', { desc = 'Toggle Neo-tree' }) + -- [[ Basic Autocommands ]] -- See `:help lua-guide-autocommands` @@ -617,6 +626,15 @@ require('lazy').setup({ -- But for many setups, the LSP (`tsserver`) will work just fine -- tsserver = {}, -- + eslint = { + -- Enable auto-fix on save + on_attach = function(client, bufnr) + vim.api.nvim_create_autocmd('BufWritePre', { + buffer = bufnr, + command = 'EslintFixAll', + }) + end, + }, lua_ls = { -- cmd = {...}, @@ -640,6 +658,12 @@ require('lazy').setup({ -- :Mason -- -- You can press `g?` for help in this menu. + local ensure_installed = vim.tbl_keys(servers or {}) + vim.list_extend(ensure_installed, { + 'stylua', -- Used to format Lua code + 'eslint-lsp', -- ESLint Language Server + }) + require('mason').setup() -- You can add other tools here that you want Mason to install @@ -681,22 +705,6 @@ require('lazy').setup({ }, opts = { notify_on_error = false, - format_on_save = function(bufnr) - -- Disable "format_on_save lsp_fallback" for languages that don't - -- have a well standardized coding style. You can add additional - -- languages here or re-enable it for the disabled ones. - local disable_filetypes = { c = true, cpp = true } - local lsp_format_opt - if disable_filetypes[vim.bo[bufnr].filetype] then - lsp_format_opt = 'never' - else - lsp_format_opt = 'fallback' - end - return { - timeout_ms = 500, - lsp_format = lsp_format_opt, - } - end, formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially @@ -823,12 +831,7 @@ require('lazy').setup({ } end, }, - - { -- You can easily change to a different colorscheme. - -- Change the name of the colorscheme plugin below, and then - -- 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', priority = 1000, -- Make sure to load this before all the other start plugins. init = function() @@ -929,7 +932,7 @@ require('lazy').setup({ -- -- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going. -- For additional information, see `:help lazy.nvim-lazy.nvim-structuring-your-plugins` - -- { import = 'custom.plugins' }, + { import = 'custom.plugins' }, }, { ui = { -- If you are using a Nerd Font: set icons to an empty table which will use the @@ -952,5 +955,6 @@ require('lazy').setup({ }, }) +vim.cmd 'highlight Normal ctermbg=none guibg=none' -- The line beneath this is called `modeline`. See `:help modeline` --- vim: ts=2 sts=2 sw=2 et +-- vim: ts=2 sts=2 sw=2 diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..f61daf46 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,445 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'folke/snacks.nvim', + priority = 1000, + lazy = false, + ---@type snacks.Config + opts = { + bigfile = { enabled = true }, + dashboard = { enabled = true }, + notifier = { + enabled = true, + timeout = 3000, + }, + quickfile = { enabled = true }, + statuscolumn = { enabled = true }, + words = { enabled = true }, + styles = { + notification = { + wo = { wrap = true }, -- Wrap notifications + }, + }, + }, + keys = { + { + 'un', + function() + Snacks.notifier.hide() + end, + desc = 'Dismiss All Notifications', + }, + { + 'bd', + function() + Snacks.bufdelete() + end, + desc = 'Delete Buffer', + }, + { + 'gg', + function() + Snacks.lazygit() + end, + desc = 'Lazygit', + }, + { + 'gb', + function() + Snacks.git.blame_line() + end, + desc = 'Git Blame Line', + }, + { + 'gB', + function() + Snacks.gitbrowse() + end, + desc = 'Git Browse', + }, + { + 'gf', + function() + Snacks.lazygit.log_file() + end, + desc = 'Lazygit Current File History', + }, + { + 'gl', + function() + Snacks.lazygit.log() + end, + desc = 'Lazygit Log (cwd)', + }, + { + 'cR', + function() + Snacks.rename.rename_file() + end, + desc = 'Rename File', + }, + { + '', + function() + Snacks.terminal() + end, + desc = 'Toggle Terminal', + }, + { + '', + function() + Snacks.terminal() + end, + desc = 'which_key_ignore', + }, + { + ']]', + function() + Snacks.words.jump(vim.v.count1) + end, + desc = 'Next Reference', + mode = { 'n', 't' }, + }, + { + '[[', + function() + Snacks.words.jump(-vim.v.count1) + end, + desc = 'Prev Reference', + mode = { 'n', 't' }, + }, + }, + init = function() + vim.api.nvim_create_autocmd('User', { + pattern = 'VeryLazy', + callback = function() + -- Setup some globals for debugging (lazy-loaded) + _G.dd = function(...) + Snacks.debug.inspect(...) + end + _G.bt = function() + Snacks.debug.backtrace() + end + vim.print = _G.dd -- Override print to use snacks for `:=` command + + -- Create some toggle mappings + Snacks.toggle.option('spell', { name = 'Spelling' }):map 'us' + Snacks.toggle.option('wrap', { name = 'Wrap' }):map 'uw' + Snacks.toggle.option('relativenumber', { name = 'Relative Number' }):map 'uL' + Snacks.toggle.diagnostics():map 'ud' + Snacks.toggle.line_number():map 'ul' + Snacks.toggle.option('conceallevel', { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2 }):map 'uc' + Snacks.toggle.treesitter():map 'uT' + Snacks.toggle.option('background', { off = 'light', on = 'dark', name = 'Dark Background' }):map 'ub' + Snacks.toggle.inlay_hints():map 'uh' + end, + }) + end, + }, + { + 'MeanderingProgrammer/render-markdown.nvim', + dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.nvim' }, -- if you use the mini.nvim suite + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'echasnovski/mini.icons' }, -- if you use standalone mini plugins + -- dependencies = { 'nvim-treesitter/nvim-treesitter', 'nvim-tree/nvim-web-devicons' }, -- if you prefer nvim-web-devicons + ---@module 'render-markdown' + ---@type render.md.UserConfig + opts = {}, + }, + { + 'yetone/avante.nvim', + event = 'VeryLazy', + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + -- add any opts here + }, + -- if you want to build from source then do `make BUILD_FROM_SOURCE=true` + build = 'make', + -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows + dependencies = { + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- The below dependencies are optional, + 'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions + 'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons + 'zbirenbaum/copilot.lua', -- for providers='copilot' + { + -- support for image pasting + 'HakonHarnes/img-clip.nvim', + event = 'VeryLazy', + opts = { + -- recommended settings + default = { + embed_image_as_base64 = false, + prompt_for_file_name = false, + drag_and_drop = { + insert_mode = true, + }, + -- required for Windows users + use_absolute_path = true, + }, + }, + }, + { + -- Make sure to set this up properly if you have lazy=true + 'MeanderingProgrammer/render-markdown.nvim', + opts = { + file_types = { 'markdown', 'Avante' }, + }, + ft = { 'markdown', 'Avante' }, + }, + }, + config = function() + require('avante').setup { + provider = 'openai', + auto_suggestions_provider = 'openai', + behaviour = { + auto_suggestions = true, -- experimental stage + auto_set_highlight_group = true, + auto_set_keymaps = true, + auto_apply_diff_after_generation = false, + support_paste_from_clipboard = true, + minimize_diff = true, -- whether to remove unchanged lines when applying a code block + }, + } + end, + }, + { + 'jose-elias-alvarez/null-ls.nvim', + config = function() + local null_ls = require 'null-ls' + + local root_has_file = function(files) + return function(utils) + return utils.root_has_file(files) + end + end + + local eslint_root_files = { '.eslintrc', '.eslintrc.js', '.eslintrc.json' } + local prettier_root_files = { '.prettierrc', '.prettierrc.js', '.prettierrc.json' } + local stylua_root_files = { 'stylua.toml', '.stylua.toml' } + local elm_root_files = { 'elm.json' } + + local opts = { + eslint_formatting = { + condition = function(utils) + local has_eslint = root_has_file(eslint_root_files)(utils) + local has_prettier = root_has_file(prettier_root_files)(utils) + return has_eslint and not has_prettier + end, + }, + eslint_diagnostics = { + condition = root_has_file(eslint_root_files), + }, + prettier_formatting = { + condition = root_has_file(prettier_root_files), + }, + stylua_formatting = { + condition = root_has_file(stylua_root_files), + }, + elm_format_formatting = { + condition = root_has_file(elm_root_files), + }, + } + + local function on_attach(client, _) + if client.server_capabilities.document_formatting then + vim.cmd 'command! -buffer Formatting lua vim.lsp.buf.formatting()' + vim.cmd 'command! -buffer FormattingSync lua vim.lsp.buf.formatting_sync()' + end + end + + null_ls.setup { + sources = { + null_ls.builtins.diagnostics.eslint_d.with(opts.eslint_diagnostics), + null_ls.builtins.formatting.eslint_d.with(opts.eslint_formatting), + null_ls.builtins.formatting.prettier.with(opts.prettier_formatting), + null_ls.builtins.formatting.stylua.with(opts.stylua_formatting), + null_ls.builtins.formatting.elm_format.with(opts.elm_format_formatting), + null_ls.builtins.code_actions.eslint_d.with(opts.eslint_diagnostics), + }, + on_attach = on_attach, + } + end, + }, + { + 'williamboman/mason.nvim', + build = ':MasonUpdate', + config = function() + require('mason').setup() + end, + }, + { + 'williamboman/mason-lspconfig.nvim', + config = function() + require('mason-lspconfig').setup { + ensure_installed = { 'lua_ls' }, -- Replace with your LSP servers + } + end, + }, + { + 'jay-babu/mason-null-ls.nvim', + config = function() + require('mason-null-ls').setup { + ensure_installed = { 'eslint', 'eslint_d', 'prettier' }, -- Replace with formatters/linters you want + automatic_installation = true, + } + end, + }, + { + 'VonHeikemen/lsp-zero.nvim', + branch = 'v4.x', + }, + { 'neovim/nvim-lspconfig' }, + { 'hrsh7th/cmp-nvim-lsp' }, + { 'hrsh7th/nvim-cmp' }, + { 'MunifTanjim/prettier.nvim' }, + { 'f-person/git-blame.nvim' }, + { + 'nvim-neo-tree/neo-tree.nvim', + branch = 'v3.x', + dependencies = { + 'nvim-lua/plenary.nvim', + 'nvim-tree/nvim-web-devicons', -- not strictly required, but recommended + 'MunifTanjim/nui.nvim', + -- "3rd/image.nvim", -- Optional image support in preview window: See `# Preview Mode` for more information + }, + }, + { + 'SmiteshP/nvim-navic', + dependencies = { + 'neovim/nvim-lspconfig', + }, + }, + { + 'folke/persistence.nvim', + event = 'BufReadPre', -- this will only start session saving when an actual file was opened + opts = { + -- add any custom options here + }, + config = function() + require('persistence').setup() + end, + }, + { + 'echasnovski/mini.nvim', + version = '*', + config = function() + require('mini.icons').setup() + require('mini.sessions').setup() + end, + }, + { + 'utilyre/barbecue.nvim', + name = 'barbecue', + version = '*', + dependencies = { + 'SmiteshP/nvim-navic', + 'nvim-tree/nvim-web-devicons', -- optional dependency + }, + opts = { + -- configurations go here + }, + config = function() + require('barbecue').setup { + create_autocmd = false, -- prevent barbecue from updating itself automatically + } + + vim.api.nvim_create_autocmd({ + 'WinScrolled', -- or WinResized on NVIM-v0.9 and higher + 'BufWinEnter', + 'CursorHold', + 'InsertLeave', + + -- include this if you have set `show_modified` to `true` + -- "BufModifiedSet", + }, { + group = vim.api.nvim_create_augroup('barbecue.updater', {}), + callback = function() + require('barbecue.ui').update() + end, + }) + end, + }, + { + 'karb94/neoscroll.nvim', + config = function() + require('neoscroll').setup { + duration_multiplier = 0.4, + } + end, + }, + { + 'xiyaowong/transparent.nvim', + config = function() + require('transparent').setup { + -- table: default groups + groups = { + 'Normal', + 'NormalNC', + 'Comment', + 'Constant', + 'Special', + 'Identifier', + 'Statement', + 'PreProc', + 'Type', + 'Underlined', + 'Todo', + 'String', + 'Function', + 'Conditional', + 'Repeat', + 'Operator', + 'Structure', + 'LineNr', + 'NonText', + 'SignColumn', + 'CursorLine', + 'CursorLineNr', + 'StatusLine', + 'StatusLineNC', + 'EndOfBuffer', + }, + -- table: additional groups that should be cleared + extra_groups = { + 'NormalFloat', + 'NvimTreeNormal', + }, + -- table: groups you don't want to clear + exclude_groups = {}, + -- function: code to be executed after highlight groups are cleared + -- Also the user event "TransparentClear" will be triggered + on_clear = function() end, + } + end, + }, + { + 'sphamba/smear-cursor.nvim', + + opts = { + -- Smear cursor when switching buffers or windows. + smear_between_buffers = true, + + -- Smear cursor when moving within line or to neighbor lines. + smear_between_neighbor_lines = true, + + -- Draw the smear in buffer space instead of screen space when scrolling + scroll_buffer_space = true, + + -- Set to `true` if your font supports legacy computing symbols (block unicode symbols). + -- Smears will blend better on all backgrounds. + legacy_computing_symbols_support = false, + + stiffness = 0.8, -- 0.6 [0, 1] + + trailing_stiffness = 0.5, -- 0.3 [0, 1] + distance_stop_animating = 0.5, -- 0.1 > 0 + hide_target_hack = false, -- true boolean + }, + }, + { 'ThePrimeagen/vim-be-good' }, +} diff --git a/lua/plugins/neoscroll.lua b/lua/plugins/neoscroll.lua new file mode 100644 index 00000000..e2c88897 --- /dev/null +++ b/lua/plugins/neoscroll.lua @@ -0,0 +1,6 @@ +return { + "karb94/neoscroll.nvim", + config = function () + require('neoscroll').setup({}) + end +}