Initial custom configurations

This commit is contained in:
J.F. Turcot 2024-10-30 23:03:58 -04:00
parent 2ba39c6973
commit 2d62fef371
16 changed files with 343 additions and 30 deletions

1
.gitignore vendored
View File

@ -5,3 +5,4 @@ nvim
spell/
lazy-lock.json
.undo

144
init.lua
View File

@ -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!

11
lua/custom/completion.lua Normal file
View File

@ -0,0 +1,11 @@
local cmp = require 'cmp'
return {
-- Setup up vim-dadbod
cmp.setup.filetype({ 'sql' }, {
sources = {
{ name = 'vim-dadbod-completion' },
{ name = 'buffer' },
},
}),
}

9
lua/custom/keymaps.lua Normal file
View File

@ -0,0 +1,9 @@
return {
vim.keymap.set('v', '>', '>gv', { desc = 'Reselect visual block after indent' }),
vim.keymap.set('v', '<', '<gv', { desc = 'Reselect visual block after outdent' }),
vim.keymap.set('n', '<left>', '<cmd>bp<CR>', { desc = 'Go to previous buffer' }),
vim.keymap.set('n', '<right>', '<cmd>bn<CR>', { desc = 'Go to next buffer' }),
vim.keymap.set('n', '<leader>db', '<cmd>DBUI<CR>', { desc = 'Dadbod UI' }),
}

7
lua/custom/options.lua Normal file
View File

@ -0,0 +1,7 @@
-- Disable line wrapping
vim.opt.wrap = false
-- Visual wrap column
vim.opt.colorcolumn = '120'
return {}

View File

@ -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' },
},
},
},
}

View File

@ -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,
}

View File

@ -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 = {
{ '<leader>gcc', '<cmd>CopilotChatToggle<cr>', desc = 'Toggle CopilotChat' },
{ '<leader>gc?', '<cmd>CopilotChatExplain<cr>', desc = 'Explain selected code with CopilotChat' },
{ '<leader>gcr', '<cmd>CopilotChatReview<cr>', desc = 'Review selected code with CopilotChat' },
},
},
}

View File

@ -0,0 +1,11 @@
return {
'tpope/vim-dadbod',
'kristijanhusak/vim-dadbod-completion',
'kristijanhusak/vim-dadbod-ui',
keys = {
{ '<leader>zz', '<cmd>DBUIToggle<cr>', desc = 'Dadbod UI' },
},
-- config = function()
-- vim.keymap.set('n', '<leader>db', '<CMD>DBUIToggle<CR>', { desc = 'Dadbod UI' })
-- end,
}

View File

@ -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', '<leader>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', '<leader>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' }),
}

View File

@ -0,0 +1,18 @@
return {
'kdheepak/lazygit.nvim',
-- optional for floating window border decoration
dependencies = {
'nvim-lua/plenary.nvim',
},
keys = {
{ '<leader>gg', '<cmd>LazyGit<cr>', 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,
}

View File

@ -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 = {
{ '\\', '<cmd>Neotree toggle<cr>', desc = 'NeoTree' },
},
}

View File

@ -0,0 +1,14 @@
return {
'vim-test/vim-test',
dependencies = {
'preservim/vimux',
},
keys = {
{ '<leader>t', '<cmd>TestNearest<cr>', desc = 'NeoTree' },
{ '<leader>T', '<cmd>TestFile<cr>', desc = 'NeoTree' },
},
config = function()
local cmd = vim.cmd
cmd 'let test#strategy = "vimux"'
end,
}

View File

@ -0,0 +1,17 @@
return {
"christoomey/vim-tmux-navigator",
cmd = {
"TmuxNavigateLeft",
"TmuxNavigateDown",
"TmuxNavigateUp",
"TmuxNavigateRight",
"TmuxNavigatePrevious",
},
keys = {
{ "<c-h>", "<cmd><C-U>TmuxNavigateLeft<cr>" },
{ "<c-j>", "<cmd><C-U>TmuxNavigateDown<cr>" },
{ "<c-k>", "<cmd><C-U>TmuxNavigateUp<cr>" },
{ "<c-l>", "<cmd><C-U>TmuxNavigateRight<cr>" },
{ "<c-\\>", "<cmd><C-U>TmuxNavigatePrevious<cr>" },
},
}

View File

@ -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,

View File

@ -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