my config
This commit is contained in:
parent
1860184830
commit
6c8c4d057d
146
init.lua
146
init.lua
|
|
@ -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.mapleader = ' '
|
||||||
vim.g.maplocalleader = ' '
|
vim.g.maplocalleader = ' '
|
||||||
|
|
||||||
-- Set to true if you have a Nerd Font installed and selected in the terminal
|
-- Set to true if you have a Nerd Font installed
|
||||||
vim.g.have_nerd_font = false
|
vim.g.have_nerd_font = true
|
||||||
|
|
||||||
-- [[ Setting options ]]
|
-- [[ Setting options ]]
|
||||||
-- See `:help vim.opt`
|
-- See `:help vim.opt`
|
||||||
|
|
@ -102,7 +102,7 @@ vim.g.have_nerd_font = false
|
||||||
vim.opt.number = true
|
vim.opt.number = true
|
||||||
-- You can also add relative line numbers, to help with jumping.
|
-- You can also add relative line numbers, to help with jumping.
|
||||||
-- Experiment for yourself to see if you like it!
|
-- 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!
|
-- Enable mouse mode, can be useful for resizing splits for example!
|
||||||
vim.opt.mouse = 'a'
|
vim.opt.mouse = 'a'
|
||||||
|
|
@ -119,7 +119,8 @@ vim.schedule(function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Enable break indent
|
-- Enable break indent
|
||||||
vim.opt.breakindent = true
|
vim.opt.autoindent = false
|
||||||
|
vim.opt.breakindent = false
|
||||||
|
|
||||||
-- Save undo history
|
-- Save undo history
|
||||||
vim.opt.undofile = true
|
vim.opt.undofile = true
|
||||||
|
|
@ -157,6 +158,9 @@ vim.opt.cursorline = true
|
||||||
-- Minimal number of screen lines to keep above and below the cursor.
|
-- Minimal number of screen lines to keep above and below the cursor.
|
||||||
vim.opt.scrolloff = 10
|
vim.opt.scrolloff = 10
|
||||||
|
|
||||||
|
-- Shorten tabstop due to forced use of tabs in golang projects
|
||||||
|
vim.o.tabstop = 4
|
||||||
|
|
||||||
-- [[ Basic Keymaps ]]
|
-- [[ Basic Keymaps ]]
|
||||||
-- See `:help vim.keymap.set()`
|
-- 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-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' })
|
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 ]]
|
-- [[ Basic Autocommands ]]
|
||||||
-- See `:help lua-guide-autocommands`
|
-- See `:help lua-guide-autocommands`
|
||||||
|
|
||||||
|
|
@ -204,6 +226,9 @@ vim.api.nvim_create_autocmd('TextYankPost', {
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
-- Filetype configs
|
||||||
|
vim.filetype.add { extension = { templ = 'templ' } }
|
||||||
|
|
||||||
-- [[ Install `lazy.nvim` plugin manager ]]
|
-- [[ Install `lazy.nvim` plugin manager ]]
|
||||||
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
|
-- See `:help lazy.nvim.txt` or https://github.com/folke/lazy.nvim for more info
|
||||||
local lazypath = vim.fn.stdpath 'data' .. '/lazy/lazy.nvim'
|
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
|
-- See `:help gitsigns` to understand what the configuration keys do
|
||||||
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
{ -- Adds git related signs to the gutter, as well as utilities for managing changes
|
||||||
'lewis6991/gitsigns.nvim',
|
'lewis6991/gitsigns.nvim',
|
||||||
opts = {
|
opts = {},
|
||||||
signs = {
|
|
||||||
add = { text = '+' },
|
|
||||||
change = { text = '~' },
|
|
||||||
delete = { text = '_' },
|
|
||||||
topdelete = { text = '‾' },
|
|
||||||
changedelete = { text = '~' },
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
-- NOTE: Plugins can also be configured to run Lua code when they are loaded.
|
-- 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' },
|
-- 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 = {
|
extensions = {
|
||||||
['ui-select'] = {
|
['ui-select'] = {
|
||||||
require('telescope.themes').get_dropdown(),
|
require('telescope.themes').get_dropdown(),
|
||||||
|
|
@ -480,7 +514,7 @@ require('lazy').setup({
|
||||||
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||||
|
|
||||||
-- Find references for the word under your cursor.
|
-- 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.
|
-- Jump to the implementation of the word under your cursor.
|
||||||
-- Useful when your language has ways of declaring types without an actual implementation.
|
-- 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/
|
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
|
||||||
local servers = {
|
local servers = {
|
||||||
-- clangd = {},
|
-- clangd = {},
|
||||||
-- gopls = {},
|
gopls = {},
|
||||||
|
templ = {
|
||||||
|
filetypes = { 'html', 'templ' },
|
||||||
|
},
|
||||||
|
html = {
|
||||||
|
filetypes = { 'html', 'templ' },
|
||||||
|
},
|
||||||
|
tailwindcss = {
|
||||||
|
filetypes = { 'html', 'templ' },
|
||||||
|
init_options = { userLanguages = { temp = 'html' } },
|
||||||
|
},
|
||||||
-- pyright = {},
|
-- pyright = {},
|
||||||
-- rust_analyzer = {},
|
-- rust_analyzer = {},
|
||||||
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
|
-- ... 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
|
-- https://github.com/pmizio/typescript-tools.nvim
|
||||||
--
|
--
|
||||||
-- But for many setups, the LSP (`tsserver`) will work just fine
|
-- But for many setups, the LSP (`tsserver`) will work just fine
|
||||||
-- tsserver = {},
|
tsserver = {
|
||||||
--
|
commands = {
|
||||||
|
OrganizeImports = {
|
||||||
|
organize_imports,
|
||||||
|
description = 'Organize Imports',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
lua_ls = {
|
lua_ls = {
|
||||||
-- cmd = {...},
|
-- cmd = {...},
|
||||||
|
|
@ -629,6 +679,22 @@ require('lazy').setup({
|
||||||
end,
|
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
|
{ -- Autoformat
|
||||||
'stevearc/conform.nvim',
|
'stevearc/conform.nvim',
|
||||||
event = { 'BufWritePre' },
|
event = { 'BufWritePre' },
|
||||||
|
|
@ -644,12 +710,12 @@ require('lazy').setup({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
opts = {
|
opts = {
|
||||||
notify_on_error = false,
|
log_level = vim.log.levels.DEBUG,
|
||||||
format_on_save = function(bufnr)
|
format_on_save = function(bufnr)
|
||||||
-- Disable "format_on_save lsp_fallback" for languages that don't
|
-- Disable "format_on_save lsp_fallback" for languages that don't
|
||||||
-- have a well standardized coding style. You can add additional
|
-- have a well standardized coding style. You can add additional
|
||||||
-- languages here or re-enable it for the disabled ones.
|
-- 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 {
|
return {
|
||||||
timeout_ms = 500,
|
timeout_ms = 500,
|
||||||
lsp_fallback = not disable_filetypes[vim.bo[bufnr].filetype],
|
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
|
-- 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 },
|
||||||
|
json = { 'prettier' },
|
||||||
|
typescript = { 'prettier' },
|
||||||
|
typescriptreact = { 'prettier' },
|
||||||
|
javascript = { 'prettier' },
|
||||||
|
javascriptreact = { 'prettier' },
|
||||||
|
solidity = { 'prettier' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -782,21 +854,15 @@ require('lazy').setup({
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
{ -- You can easily change to a different colorscheme.
|
{
|
||||||
-- Change the name of the colorscheme plugin below, and then
|
'catppuccin/nvim',
|
||||||
-- change the command in the config to whatever the name of that colorscheme is.
|
name = 'catppuccin',
|
||||||
--
|
priority = 1000,
|
||||||
-- If you want to see what colorschemes are already installed, you can use `:Telescope colorscheme`.
|
config = function()
|
||||||
'folke/tokyonight.nvim',
|
-- This is the function that runs, AFTER loading
|
||||||
priority = 1000, -- Make sure to load this before all the other start plugins.
|
require('catppuccin').setup { flavour = 'mocha' }
|
||||||
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'
|
|
||||||
|
|
||||||
-- You can configure highlights by doing something like:
|
vim.cmd.colorscheme 'catppuccin'
|
||||||
vim.cmd.hi 'Comment gui=none'
|
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -844,7 +910,7 @@ require('lazy').setup({
|
||||||
'nvim-treesitter/nvim-treesitter',
|
'nvim-treesitter/nvim-treesitter',
|
||||||
build = ':TSUpdate',
|
build = ':TSUpdate',
|
||||||
opts = {
|
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
|
-- Autoinstall languages that are not installed
|
||||||
auto_install = true,
|
auto_install = true,
|
||||||
highlight = {
|
highlight = {
|
||||||
|
|
@ -852,9 +918,9 @@ require('lazy').setup({
|
||||||
-- Some languages depend on vim's regex highlighting system (such as Ruby) for indent rules.
|
-- 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
|
-- If you are experiencing weird indenting issues, add the language to
|
||||||
-- the list of additional_vim_regex_highlighting and disabled languages for indent.
|
-- 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)
|
config = function(_, opts)
|
||||||
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
-- [[ Configure Treesitter ]] See `:help nvim-treesitter`
|
||||||
|
|
@ -886,6 +952,12 @@ require('lazy').setup({
|
||||||
-- require 'kickstart.plugins.autopairs',
|
-- require 'kickstart.plugins.autopairs',
|
||||||
-- require 'kickstart.plugins.neo-tree',
|
-- require 'kickstart.plugins.neo-tree',
|
||||||
-- require 'kickstart.plugins.gitsigns', -- adds gitsigns recommend keymaps
|
-- 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`
|
-- 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.
|
-- This is the easiest way to modularize your config.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue