From 2d62fef3717ce5075d379c76b521368cec8f297d Mon Sep 17 00:00:00 2001 From: "J.F. Turcot" Date: Wed, 30 Oct 2024 23:03:58 -0400 Subject: [PATCH] Initial custom configurations --- .gitignore | 1 + init.lua | 144 +++++++++++++++++----- lua/custom/completion.lua | 11 ++ lua/custom/keymaps.lua | 9 ++ lua/custom/options.lua | 7 ++ lua/custom/plugins/avente.lua | 46 +++++++ lua/custom/plugins/catppuccin.lua | 12 ++ lua/custom/plugins/copilot.lua | 47 +++++++ lua/custom/plugins/dadbod.lua | 11 ++ lua/custom/plugins/init.lua | 14 ++- lua/custom/plugins/lazygit.lua | 18 +++ lua/custom/plugins/neo-tree.lua | 12 ++ lua/custom/plugins/vim-test.lua | 14 +++ lua/custom/plugins/vim-tmux-navigator.lua | 17 +++ lua/kickstart/plugins/lint.lua | 4 + lua/scripts/lazygit-open-file.lua | 6 + 16 files changed, 343 insertions(+), 30 deletions(-) create mode 100644 lua/custom/completion.lua create mode 100644 lua/custom/keymaps.lua create mode 100644 lua/custom/options.lua create mode 100644 lua/custom/plugins/avente.lua create mode 100644 lua/custom/plugins/catppuccin.lua create mode 100644 lua/custom/plugins/copilot.lua create mode 100644 lua/custom/plugins/dadbod.lua create mode 100644 lua/custom/plugins/lazygit.lua create mode 100644 lua/custom/plugins/neo-tree.lua create mode 100644 lua/custom/plugins/vim-test.lua create mode 100644 lua/custom/plugins/vim-tmux-navigator.lua create mode 100644 lua/scripts/lazygit-open-file.lua diff --git a/.gitignore b/.gitignore index 005b535b606..adde469e6c7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ nvim spell/ lazy-lock.json +.undo diff --git a/init.lua b/init.lua index 4ce35f4b5c4..ca3a2046f73 100644 --- a/init.lua +++ b/init.lua @@ -91,7 +91,7 @@ vim.g.mapleader = ' ' vim.g.maplocalleader = ' ' -- Set to true if you have a Nerd Font installed and selected in the terminal -vim.g.have_nerd_font = false +vim.g.have_nerd_font = true -- [[ Setting options ]] -- See `:help vim.opt` @@ -114,15 +114,16 @@ vim.opt.showmode = false -- Schedule the setting after `UiEnter` because it can increase startup-time. -- Remove this option if you want your OS clipboard to remain independent. -- See `:help 'clipboard'` -vim.schedule(function() - vim.opt.clipboard = 'unnamedplus' -end) +-- vim.schedule(function() +-- vim.opt.clipboard = 'unnamedplus' +-- end) -- Enable break indent vim.opt.breakindent = true -- Save undo history vim.opt.undofile = true +vim.opt.undodir = vim.fn.stdpath 'config' .. '/.undo' -- Case-insensitive searching UNLESS \C or one or more capital letters in the search term vim.opt.ignorecase = true @@ -253,6 +254,7 @@ require('lazy').setup({ topdelete = { text = '‾' }, changedelete = { text = '~' }, }, + current_line_blame = true, }, }, @@ -615,18 +617,49 @@ require('lazy').setup({ -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { -- clangd = {}, - -- gopls = {}, - -- pyright = {}, - -- rust_analyzer = {}, + gopls = {}, + pyright = {}, + rust_analyzer = {}, -- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs -- -- Some languages (like typescript) have entire language plugins that can be useful: -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, + ts_ls = {}, -- + html = {}, + tailwindcss = {}, + graphql = { + filetypes = { 'graphql', 'gql', 'typescriptreact', 'javascriptreact' }, + }, + + ruby_lsp = {}, + rubocop = { + -- See: https://docs.rubocop.org/rubocop/usage/lsp.html + root_dir = require('lspconfig').util.root_pattern('Gemfile', '.git', '.'), + }, + -- solargraph = { + -- -- cmd = { os.getenv 'HOME' .. '/.asdf/shims/solargraph', 'stdio' }, + -- root_dir = require('lspconfig').util.root_pattern('Gemfile', '.git', '.'), + -- settings = { + -- solargraph = { + -- autoformat = true, + -- completion = true, + -- diagnostics = true, + -- folding = true, + -- references = true, + -- rename = true, + -- symbols = true, + -- }, + -- }, + -- flags = { + -- debounce_text_changes = 300, + -- }, + -- }, + -- stimulus_ls = {}, + lua_ls = { -- cmd = {...}, -- filetypes = { ...}, @@ -656,6 +689,14 @@ require('lazy').setup({ local ensure_installed = vim.tbl_keys(servers or {}) vim.list_extend(ensure_installed, { 'stylua', -- Used to format Lua code + 'isort', + 'black', + 'prettier', + 'erb-formatter', + 'markdownlint', + 'eslint', + 'goimports', + -- 'sqlfmt', }) require('mason-tool-installer').setup { ensure_installed = ensure_installed } @@ -702,17 +743,30 @@ require('lazy').setup({ lsp_format_opt = 'fallback' end return { - timeout_ms = 500, + timeout_ms = 1500, lsp_format = lsp_format_opt, } end, formatters_by_ft = { lua = { 'stylua' }, -- Conform can also run multiple formatters sequentially - -- python = { "isort", "black" }, + python = { 'isort', 'black' }, -- -- You can use 'stop_after_first' to run the first available formatter from the list - -- javascript = { "prettierd", "prettier", stop_after_first = true }, + javascript = { 'prettierd', 'prettier', stop_after_first = true }, + javascriptreact = { 'prettier' }, + typescript = { 'prettier' }, + typescriptreact = { 'prettier' }, + css = { 'prettier' }, + html = { 'prettier' }, + json = { 'prettier' }, + yaml = { 'prettier' }, + markdown = { 'prettier' }, + graphql = { 'prettier' }, + ruby = { 'rubocop' }, + eruby = { 'erb_format' }, + go = { 'goimports', 'gofmt' }, + -- sql = { 'sqlfmt' }, }, }, }, @@ -825,9 +879,11 @@ require('lazy').setup({ -- set group index to 0 to skip loading LuaLS completions as lazydev recommends it group_index = 0, }, - { name = 'nvim_lsp' }, - { name = 'luasnip' }, - { name = 'path' }, + { name = 'copilot', group_index = 2 }, + { name = 'nvim_lsp', group_index = 2 }, + { name = 'luasnip', group_index = 2 }, + { name = 'path', group_index = 2 }, + { name = 'buffer', group_index = 2 }, }, } end, @@ -897,17 +953,46 @@ require('lazy').setup({ 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', + 'go', + 'html', + 'javascript', + 'jsdoc', + 'json', + 'jsonc', + 'lua', + 'luadoc', + 'luap', + 'markdown', + 'markdown_inline', + 'python', + 'query', + 'regex', + 'ruby', + 'rust', + 'toml', + 'tsx', + 'typescript', + 'vim', + 'vimdoc', + 'xml', + 'yaml', + }, -- Autoinstall languages that are not installed auto_install = true, - highlight = { - enable = true, - -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. - -- If you are experiencing weird indenting issues, add the language to - -- the list of additional_vim_regex_highlighting and disabled languages for indent. - additional_vim_regex_highlighting = { 'ruby' }, - }, - indent = { enable = true, disable = { 'ruby' } }, + highlight = { enable = true }, + indent = { enable = true }, + -- highlight = { + -- enable = true, + -- -- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules. + -- -- If you are experiencing weird indenting issues, add the language to + -- -- the list of additional_vim_regex_highlighting and disabled languages for indent. + -- additional_vim_regex_highlighting = { 'ruby' }, + -- }, + -- indent = { enable = true, disable = { 'ruby' } }, }, -- There are additional nvim-treesitter modules that you can use to interact -- with nvim-treesitter. You should go explore a few and see what interests you: @@ -927,17 +1012,18 @@ require('lazy').setup({ -- Uncomment any of the lines below to enable them (you will need to restart nvim). -- -- require 'kickstart.plugins.debug', - -- require 'kickstart.plugins.indent_line', - -- require 'kickstart.plugins.lint', - -- require 'kickstart.plugins.autopairs', - -- require 'kickstart.plugins.neo-tree', - -- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps + require 'kickstart.plugins.indent_line', + require 'kickstart.plugins.lint', + require 'kickstart.plugins.autopairs', + require 'kickstart.plugins.neo-tree', + require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps -- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua` -- 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' }, + { import = 'custom' }, -- -- For additional information with loading, sourcing and examples see `:help lazy.nvim-🔌-plugin-spec` -- Or use telescope! diff --git a/lua/custom/completion.lua b/lua/custom/completion.lua new file mode 100644 index 00000000000..83ef47e6f31 --- /dev/null +++ b/lua/custom/completion.lua @@ -0,0 +1,11 @@ +local cmp = require 'cmp' + +return { + -- Setup up vim-dadbod + cmp.setup.filetype({ 'sql' }, { + sources = { + { name = 'vim-dadbod-completion' }, + { name = 'buffer' }, + }, + }), +} diff --git a/lua/custom/keymaps.lua b/lua/custom/keymaps.lua new file mode 100644 index 00000000000..74b10c09809 --- /dev/null +++ b/lua/custom/keymaps.lua @@ -0,0 +1,9 @@ +return { + vim.keymap.set('v', '>', '>gv', { desc = 'Reselect visual block after indent' }), + vim.keymap.set('v', '<', '', 'bp', { desc = 'Go to previous buffer' }), + vim.keymap.set('n', '', 'bn', { desc = 'Go to next buffer' }), + + vim.keymap.set('n', 'db', 'DBUI', { desc = 'Dadbod UI' }), +} diff --git a/lua/custom/options.lua b/lua/custom/options.lua new file mode 100644 index 00000000000..aad01133dd6 --- /dev/null +++ b/lua/custom/options.lua @@ -0,0 +1,7 @@ +-- Disable line wrapping +vim.opt.wrap = false + +-- Visual wrap column +vim.opt.colorcolumn = '120' + +return {} diff --git a/lua/custom/plugins/avente.lua b/lua/custom/plugins/avente.lua new file mode 100644 index 00000000000..154aca442e8 --- /dev/null +++ b/lua/custom/plugins/avente.lua @@ -0,0 +1,46 @@ +return { + { + 'yetone/avante.nvim', + event = 'VeryLazy', + lazy = false, + version = false, -- set this if you want to always pull the latest change + opts = { + provider = 'copilot', + }, + build = 'make', + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'stevearc/dressing.nvim', + 'nvim-lua/plenary.nvim', + 'MunifTanjim/nui.nvim', + --- The below dependencies are optional, + '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' }, + }, + }, + }, +} diff --git a/lua/custom/plugins/catppuccin.lua b/lua/custom/plugins/catppuccin.lua new file mode 100644 index 00000000000..fe0ee2baa80 --- /dev/null +++ b/lua/custom/plugins/catppuccin.lua @@ -0,0 +1,12 @@ +return { + 'catppuccin/nvim', + name = 'catppuccin', + priority = 1001, + + init = function() + vim.cmd.colorscheme 'catppuccin-frappe' + + -- You can configure highlights by doing something like: + vim.cmd.hi 'Comment gui=none' + end, +} diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua new file mode 100644 index 00000000000..63c6884577b --- /dev/null +++ b/lua/custom/plugins/copilot.lua @@ -0,0 +1,47 @@ +return { + -- copilot + { + 'zbirenbaum/copilot.lua', + cmd = 'Copilot', + build = ':Copilot auth', + opts = { + suggestion = { enabled = false }, + panel = { enabled = false }, + }, + }, + + -- copilot cmp source + { + 'nvim-cmp', + dependencies = { + { + 'zbirenbaum/copilot-cmp', + dependencies = 'copilot.lua', + opts = {}, + config = function() + require('copilot_cmp').setup() + end, + }, + }, + }, + + -- copilot chat + { + 'CopilotC-Nvim/CopilotChat.nvim', + branch = 'canary', + dependencies = { + { 'zbirenbaum/copilot.lua' }, -- or github/copilot.vim + { 'nvim-lua/plenary.nvim' }, -- for curl, log wrapper + }, + opts = { + -- debug = true, -- Enable debugging + -- See Configuration section for rest + }, + -- See Commands section for default commands if you want to lazy load on them + keys = { + { 'gcc', 'CopilotChatToggle', desc = 'Toggle CopilotChat' }, + { 'gc?', 'CopilotChatExplain', desc = 'Explain selected code with CopilotChat' }, + { 'gcr', 'CopilotChatReview', desc = 'Review selected code with CopilotChat' }, + }, + }, +} diff --git a/lua/custom/plugins/dadbod.lua b/lua/custom/plugins/dadbod.lua new file mode 100644 index 00000000000..859569f4bc3 --- /dev/null +++ b/lua/custom/plugins/dadbod.lua @@ -0,0 +1,11 @@ +return { + 'tpope/vim-dadbod', + 'kristijanhusak/vim-dadbod-completion', + 'kristijanhusak/vim-dadbod-ui', + keys = { + { 'zz', 'DBUIToggle', desc = 'Dadbod UI' }, + }, + -- config = function() + -- vim.keymap.set('n', 'db', 'DBUIToggle', { desc = 'Dadbod UI' }) + -- end, +} diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8d7a..18a94814c5c 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,16 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + vim.keymap.set('n', 'bc', function() + local path = vim.fn.expand '%:.' + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') + end, { desc = 'Copy relative path of the buffer to clipboard' }), + + vim.keymap.set('n', 'bca', function() + local path = vim.fn.expand '%' + vim.fn.setreg('+', path) + vim.notify('Copied "' .. path .. '" to the clipboard!') + end, { desc = 'Copy absolute path of the buffer to clipboard' }), +} diff --git a/lua/custom/plugins/lazygit.lua b/lua/custom/plugins/lazygit.lua new file mode 100644 index 00000000000..f1af49d3c78 --- /dev/null +++ b/lua/custom/plugins/lazygit.lua @@ -0,0 +1,18 @@ +return { + 'kdheepak/lazygit.nvim', + -- optional for floating window border decoration + dependencies = { + 'nvim-lua/plenary.nvim', + }, + keys = { + { 'gg', 'LazyGit', desc = 'LazyGit' }, + }, + config = function() + -- set env + local env = vim.env -- for conciseness + + if vim.fn.executable 'nvr' == 1 then + env.GIT_EDITOR = "nvr --remote-wait +'set bufhidden=delete'" + end + end, +} diff --git a/lua/custom/plugins/neo-tree.lua b/lua/custom/plugins/neo-tree.lua new file mode 100644 index 00000000000..9052ffc38b4 --- /dev/null +++ b/lua/custom/plugins/neo-tree.lua @@ -0,0 +1,12 @@ +return { + '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', + }, + keys = { + { '\\', 'Neotree toggle', desc = 'NeoTree' }, + }, +} diff --git a/lua/custom/plugins/vim-test.lua b/lua/custom/plugins/vim-test.lua new file mode 100644 index 00000000000..514e5f03d33 --- /dev/null +++ b/lua/custom/plugins/vim-test.lua @@ -0,0 +1,14 @@ +return { + 'vim-test/vim-test', + dependencies = { + 'preservim/vimux', + }, + keys = { + { 't', 'TestNearest', desc = 'NeoTree' }, + { 'T', 'TestFile', desc = 'NeoTree' }, + }, + config = function() + local cmd = vim.cmd + cmd 'let test#strategy = "vimux"' + end, +} diff --git a/lua/custom/plugins/vim-tmux-navigator.lua b/lua/custom/plugins/vim-tmux-navigator.lua new file mode 100644 index 00000000000..4421fed9a43 --- /dev/null +++ b/lua/custom/plugins/vim-tmux-navigator.lua @@ -0,0 +1,17 @@ +return { + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + }, + keys = { + { "", "TmuxNavigateLeft" }, + { "", "TmuxNavigateDown" }, + { "", "TmuxNavigateUp" }, + { "", "TmuxNavigateRight" }, + { "", "TmuxNavigatePrevious" }, + }, +} diff --git a/lua/kickstart/plugins/lint.lua b/lua/kickstart/plugins/lint.lua index 907c6bf3e31..fecb16fe46b 100644 --- a/lua/kickstart/plugins/lint.lua +++ b/lua/kickstart/plugins/lint.lua @@ -7,6 +7,10 @@ return { local lint = require 'lint' lint.linters_by_ft = { markdown = { 'markdownlint' }, + javascript = { 'eslint' }, + javascriptreact = { 'eslint' }, + typescript = { 'eslint' }, + typescriptreact = { 'eslint' }, } -- To allow other plugins to add linters to require('lint').linters_by_ft, diff --git a/lua/scripts/lazygit-open-file.lua b/lua/scripts/lazygit-open-file.lua new file mode 100644 index 00000000000..ae013ec38f4 --- /dev/null +++ b/lua/scripts/lazygit-open-file.lua @@ -0,0 +1,6 @@ +return function(filename, line_number) + line_number = tonumber(line_number) or 1 + + vim.api.nvim_win_close(0, true) + vim.api.nvim_command('edit +' .. line_number .. ' ' .. filename) +end