my config

This commit is contained in:
Andrei Debono 2024-08-18 19:17:07 +02:00
parent 1860184830
commit 6c8c4d057d
1 changed files with 109 additions and 37 deletions

146
init.lua
View File

@ -90,8 +90,8 @@ P.S. You can delete this when you're done too. It's your config now! :)
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
-- Set to true if you have a Nerd Font installed
vim.g.have_nerd_font = true
-- [[ Setting options ]]
-- See `:help vim.opt`
@ -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'
@ -119,7 +119,8 @@ vim.schedule(function()
end)
-- Enable break indent
vim.opt.breakindent = true
vim.opt.autoindent = false
vim.opt.breakindent = false
-- Save undo history
vim.opt.undofile = true
@ -157,6 +158,9 @@ vim.opt.cursorline = true
-- Minimal number of screen lines to keep above and below the cursor.
vim.opt.scrolloff = 10
-- Shorten tabstop due to forced use of tabs in golang projects
vim.o.tabstop = 4
-- [[ Basic Keymaps ]]
-- See `:help vim.keymap.set()`
@ -190,6 +194,24 @@ vim.keymap.set('n', '<C-l>', '<C-w><C-l>', { desc = 'Move focus to the right win
vim.keymap.set('n', '<C-j>', '<C-w><C-j>', { desc = 'Move focus to the lower window' })
vim.keymap.set('n', '<C-k>', '<C-w><C-k>', { desc = 'Move focus to the upper window' })
-- Keybinds for Gitsigns
vim.keymap.set('n', '<leader>gp', '<cmd>Gitsigns preview_hunk<CR>', { desc = 'Preview git hunk' })
vim.keymap.set('n', '<leader>gs', '<cmd>Gitsigns toggle_current_line_blame<CR>', { desc = 'Preview git hunk' })
-- Organise imports
local function organize_imports()
local params = {
command = '_typescript.organizeImports',
arguments = { vim.api.nvim_buf_get_name(0) },
title = '',
}
vim.lsp.buf.execute_command(params)
end
vim.keymap.set('n', 'gO', '<cmd>OrganizeImports<CR>', { desc = 'Organize imports' })
vim.keymap.set('n', '<leader>U', vim.cmd.UndotreeToggle)
-- [[ Basic Autocommands ]]
-- See `:help lua-guide-autocommands`
@ -204,6 +226,9 @@ vim.api.nvim_create_autocmd('TextYankPost', {
end,
})
-- Filetype configs
vim.filetype.add { extension = { templ = 'templ' } }
-- [[ Install `lazy.nvim` plugin manager ]]
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
@ -245,15 +270,7 @@ require('lazy').setup({
-- See `:help gitsigns` to understand what the configuration keys do
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
'lewis6991/gitsigns.nvim',
opts = {
signs = {
add = { text = '+' },
change = { text = '~' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
},
opts = {},
},
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
@ -352,7 +369,24 @@ require('lazy').setup({
-- i = { ['<c-enter>'] = 'to_fuzzy_refine' },
-- },
-- },
-- pickers = {}
pickers = {
find_files = {
find_command = {
'rg',
'--no-ignore',
'--hidden',
'--files',
'-g',
'!**/node_modules/*',
'-g',
'!**/.git/*',
'-g',
'!**/build/*',
'-g',
'!**/vendor/*',
},
},
},
extensions = {
['ui-select'] = {
require('telescope.themes').get_dropdown(),
@ -480,7 +514,7 @@ require('lazy').setup({
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
-- Find references for the word under your cursor.
map('gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
map('<leader>gr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
-- Jump to the implementation of the word under your cursor.
-- Useful when your language has ways of declaring types without an actual implementation.
@ -570,7 +604,17 @@ 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 = {},
gopls = {},
templ = {
filetypes = { 'html', 'templ' },
},
html = {
filetypes = { 'html', 'templ' },
},
tailwindcss = {
filetypes = { 'html', 'templ' },
init_options = { userLanguages = { temp = 'html' } },
},
-- pyright = {},
-- rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
@ -579,8 +623,14 @@ require('lazy').setup({
-- https://github.com/pmizio/typescript-tools.nvim
--
-- But for many setups, the LSP (`tsserver`) will work just fine
-- tsserver = {},
--
tsserver = {
commands = {
OrganizeImports = {
organize_imports,
description = 'Organize Imports',
},
},
},
lua_ls = {
-- cmd = {...},
@ -629,6 +679,22 @@ require('lazy').setup({
end,
},
{
'mistricky/codesnap.nvim',
build = 'make build_generator',
keys = {
{ '<leader>cc', '<CMD>CodeSnap<CR>', mode = 'x', desc = 'Save selected code snapshot into clipboard' },
{ '<leader>cs', '<CMD>CodeSnapSave<CR>', mode = 'x', desc = 'Save selected code snapshot into ~/Pictures' },
},
opts = {
save_path = '~/Pictures',
has_breadcrumbs = true,
has_line_number = true,
bg_theme = 'dusk',
watermark = '',
},
},
{ -- Autoformat
'stevearc/conform.nvim',
event = { 'BufWritePre' },
@ -644,12 +710,12 @@ require('lazy').setup({
},
},
opts = {
notify_on_error = false,
log_level = vim.log.levels.DEBUG,
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 disable_filetypes = { c = true, cpp = true, tsx = true, ts = true, typescript = true }
return {
timeout_ms = 500,
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
@ -662,6 +728,12 @@ require('lazy').setup({
--
-- You can use 'stop_after_first' to run the first available formatter from the list
-- javascript = { "prettierd", "prettier", stop_after_first = true },
json = { 'prettier' },
typescript = { 'prettier' },
typescriptreact = { 'prettier' },
javascript = { 'prettier' },
javascriptreact = { 'prettier' },
solidity = { 'prettier' },
},
},
},
@ -782,21 +854,15 @@ 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()
-- 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'
{
'catppuccin/nvim',
name = 'catppuccin',
priority = 1000,
config = function()
-- This is the function that runs, AFTER loading
require('catppuccin').setup { flavour = 'mocha' }
-- You can configure highlights by doing something like:
vim.cmd.hi 'Comment gui=none'
vim.cmd.colorscheme 'catppuccin'
end,
},
@ -844,7 +910,7 @@ require('lazy').setup({
'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate',
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', 'templ' },
-- Autoinstall languages that are not installed
auto_install = true,
highlight = {
@ -852,9 +918,9 @@ require('lazy').setup({
-- 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' },
additional_vim_regex_highlighting = { 'ruby', 'templ' },
},
indent = { enable = true, disable = { 'ruby' } },
indent = { enable = true, disable = { 'ruby', 'typescript', 'javascript' } },
},
config = function(_, opts)
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
@ -886,6 +952,12 @@ require('lazy').setup({
-- require 'kickstart.plugins.autopairs',
-- require 'kickstart.plugins.neo-tree',
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
{
'tpope/vim-fugitive',
name = 'vim-fugitive',
},
{ 'mbbill/undotree', name = 'undotree' },
-- 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.