Правки nvim конфига
This commit is contained in:
		
							parent
							
								
									7e3d15704b
								
							
						
					
					
						commit
						e9a2f811b7
					
				
					 15 changed files with 313 additions and 166 deletions
				
			
		| 
						 | 
				
			
			@ -26,4 +26,3 @@ require("keymaps")
 | 
			
		|||
require("autocommands")
 | 
			
		||||
require("lsp")
 | 
			
		||||
require("dap")
 | 
			
		||||
require("onedark").load()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,34 +1,37 @@
 | 
			
		|||
{
 | 
			
		||||
  "LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
 | 
			
		||||
  "LuaSnip": { "branch": "master", "commit": "458560534a73f7f8d7a11a146c801db00b081df0" },
 | 
			
		||||
  "auto-save.nvim": { "branch": "main", "commit": "29f793a3a7f98129387590269ffe3ad61ab5e509" },
 | 
			
		||||
  "cmp-buffer": { "branch": "main", "commit": "b74fab3656eea9de20a9b8116afa3cfc4ec09657" },
 | 
			
		||||
  "cmp-nvim-lsp": { "branch": "main", "commit": "a8912b88ce488f411177fc8aed358b04dc246d7b" },
 | 
			
		||||
  "cmp-path": { "branch": "main", "commit": "c6635aae33a50d6010bf1aa756ac2398a2d54c32" },
 | 
			
		||||
  "cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
 | 
			
		||||
  "conform.nvim": { "branch": "master", "commit": "372fc521f8421b7830ea6db4d6ea3bae1c77548c" },
 | 
			
		||||
  "conform.nvim": { "branch": "master", "commit": "374aaf384e2e841607b8e2fe63fa3ad01d111c91" },
 | 
			
		||||
  "friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
 | 
			
		||||
  "go.nvim": { "branch": "master", "commit": "37ec4d9be3edef64b725bfe29684e1fe019873bc" },
 | 
			
		||||
  "goerr-nvim": { "branch": "main", "commit": "d30ba1cab652e78dbf6a644eb4823be57e9af203" },
 | 
			
		||||
  "goimpl.nvim": { "branch": "main", "commit": "2548d42c4db0645dea14f27e67c4b19b7030f1cf" },
 | 
			
		||||
  "guihua.lua": { "branch": "master", "commit": "0cc9631914ffcbe3e474e809c610d12a75b660cf" },
 | 
			
		||||
  "headlines.nvim": { "branch": "master", "commit": "bf17c96a836ea27c0a7a2650ba385a7783ed322e" },
 | 
			
		||||
  "indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
 | 
			
		||||
  "lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
 | 
			
		||||
  "lsp_signature.nvim": { "branch": "master", "commit": "a793d02b6a5e639fa9d3f2a89a839fa688ab2d0a" },
 | 
			
		||||
  "lsp_signature.nvim": { "branch": "master", "commit": "a4e3c15dfdce8783c074539b1835edae75fa63d5" },
 | 
			
		||||
  "lspsaga.nvim": { "branch": "main", "commit": "920b1253e1a26732e53fac78412f6da7f674671d" },
 | 
			
		||||
  "lualine.nvim": { "branch": "master", "commit": "15884cee63a8c205334ab13ab1c891cd4d27101a" },
 | 
			
		||||
  "neoscroll.nvim": { "branch": "master", "commit": "f957373912e88579e26fdaea4735450ff2ef5c9c" },
 | 
			
		||||
  "nvim-cmp": { "branch": "main", "commit": "b5311ab3ed9c846b585c0c15b7559be131ec4be9" },
 | 
			
		||||
  "nvim-dap": { "branch": "master", "commit": "8df427aeba0a06c6577dc3ab82de3076964e3b8d" },
 | 
			
		||||
  "nvim-dap-go": { "branch": "main", "commit": "8763ced35b19c8dc526e04a70ab07c34e11ad064" },
 | 
			
		||||
  "nvim-dap-ui": { "branch": "master", "commit": "73a26abf4941aa27da59820fd6b028ebcdbcf932" },
 | 
			
		||||
  "nvim-lspconfig": { "branch": "master", "commit": "1b801f68d09e70e59e6dd967b663b6d84ee3e87d" },
 | 
			
		||||
  "nvim-lspconfig": { "branch": "master", "commit": "61e5109c8cf24807e4ae29813a3a82b31821dd45" },
 | 
			
		||||
  "nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
 | 
			
		||||
  "nvim-tree.lua": { "branch": "master", "commit": "582ae48c9e43d2bcd55dfcc8e2e7a1f29065d924" },
 | 
			
		||||
  "nvim-treesitter": { "branch": "master", "commit": "94ea4f436d2b59c80f02e293466c374584f03b8c" },
 | 
			
		||||
  "nvim-treesitter-context": { "branch": "master", "commit": "6daca3ad780f045550b820f262002f35175a6c04" },
 | 
			
		||||
  "nvim-treesitter-textobjects": { "branch": "master", "commit": "ed373482db797bbf71bdff37a15c7555a84dce47" },
 | 
			
		||||
  "nvim-web-devicons": { "branch": "master", "commit": "2c2b4eafce6cdd0cb165036faa17396eff18f847" },
 | 
			
		||||
  "onedark.nvim": { "branch": "master", "commit": "0e5512d1bebd1f08954710086f87a5caa173a924" },
 | 
			
		||||
  "nvim-tree.lua": { "branch": "master", "commit": "e7d1b7dadc62fe2eccc17d814354b0a5688621ce" },
 | 
			
		||||
  "nvim-treesitter": { "branch": "master", "commit": "28d480e0624b259095e56f353ec911f9f2a0f404" },
 | 
			
		||||
  "nvim-treesitter-context": { "branch": "master", "commit": "5c48b8ba1b0b7b25feb6e34e7eb293ea893aedc4" },
 | 
			
		||||
  "nvim-treesitter-textobjects": { "branch": "master", "commit": "0e3be38005e9673d044e994b1e4b123adb040179" },
 | 
			
		||||
  "nvim-ts-autotag": { "branch": "main", "commit": "a1d526af391f6aebb25a8795cbc05351ed3620b5" },
 | 
			
		||||
  "nvim-web-devicons": { "branch": "master", "commit": "f1420728f59843eb2ef084406b3d0201a0a0932d" },
 | 
			
		||||
  "onedark.nvim": { "branch": "master", "commit": "11de4da47f3e69cb70c3ae9816bd8af166cbe121" },
 | 
			
		||||
  "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
 | 
			
		||||
  "popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
 | 
			
		||||
  "smartcolumn.nvim": { "branch": "main", "commit": "92f3773af80d674f1eb61e112dca79e2fa449fd1" },
 | 
			
		||||
  "telescope.nvim": { "branch": "master", "commit": "a4ed82509cecc56df1c7138920a1aeaf246c0ac5" }
 | 
			
		||||
  "telescope.nvim": { "branch": "master", "commit": "b4da76be54691e854d3e0e02c36b0245f945c2c7" }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,13 +69,6 @@ vim.api.nvim_create_autocmd("TextYankPost", {
 | 
			
		|||
	end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufReadPost", "FileReadPost" }, {
 | 
			
		||||
	pattern = "*",
 | 
			
		||||
	callback = function()
 | 
			
		||||
		vim.cmd("normal! zR")
 | 
			
		||||
	end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
vim.api.nvim_create_autocmd("BufEnter", {
 | 
			
		||||
	callback = function()
 | 
			
		||||
		if vim.bo.filetype == "NvimTree" or vim.fn.expand("%") == "" then
 | 
			
		||||
| 
						 | 
				
			
			@ -92,6 +85,33 @@ vim.api.nvim_create_autocmd("BufEnter", {
 | 
			
		|||
	end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufEnter", "BufAdd", "BufNew", "BufNewFile", "BufWinEnter" }, {
 | 
			
		||||
	group = vim.api.nvim_create_augroup("TS_FOLD_WORKAROUND", {}),
 | 
			
		||||
	callback = function()
 | 
			
		||||
		vim.opt.foldmethod = "expr"
 | 
			
		||||
		vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
 | 
			
		||||
	end,
 | 
			
		||||
})
 | 
			
		||||
vim.api.nvim_create_autocmd("FileType", {
 | 
			
		||||
    pattern = "*",
 | 
			
		||||
    callback = function(args)
 | 
			
		||||
        local buf = args.buf
 | 
			
		||||
        local ft = vim.bo[buf].filetype
 | 
			
		||||
 | 
			
		||||
        if ft and ft ~= "" then
 | 
			
		||||
            local has_parser, _ = pcall(vim.treesitter.language.get_lang, ft)
 | 
			
		||||
            if has_parser then
 | 
			
		||||
                pcall(vim.treesitter.start, buf, ft)
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
})
 | 
			
		||||
vim.api.nvim_create_autocmd("User", {
 | 
			
		||||
	pattern = "TSUpdate",
 | 
			
		||||
	callback = function()
 | 
			
		||||
		vim.cmd([[TSEnable highlight]])
 | 
			
		||||
	end,
 | 
			
		||||
})
 | 
			
		||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
 | 
			
		||||
	pattern = "*.templ",
 | 
			
		||||
	callback = function()
 | 
			
		||||
| 
						 | 
				
			
			@ -146,6 +166,14 @@ vim.api.nvim_create_autocmd("FileType", {
 | 
			
		|||
		vim.opt_local.cindent = false
 | 
			
		||||
	end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
vim.api.nvim_create_autocmd("VimResized", {
 | 
			
		||||
	pattern = "*",
 | 
			
		||||
	callback = function()
 | 
			
		||||
		vim.opt.scrolloff = vim.fn.floor(vim.fn.winheight(0) / 2)
 | 
			
		||||
	end,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- vim.api.nvim_create_autocmd("InsertEnter", {
 | 
			
		||||
-- 	pattern = "*",
 | 
			
		||||
-- 	command = "set norelativenumber",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,8 +23,8 @@ map("v", ">", ">gv", { noremap = true, silent = true })
 | 
			
		|||
kmap("n", "<leader>bn", "<cmd>bnext<CR>", { noremap = true, silent = true, desc = "Next buffer" })
 | 
			
		||||
kmap("n", "<leader>bp", "<cmd>bprevious<CR>", { noremap = true, silent = true, desc = "Previous buffer" })
 | 
			
		||||
kmap("n", "<leader>bd", "<cmd>bdelete<CR>", { noremap = true, silent = true, desc = "Delete buffer" })
 | 
			
		||||
kmap("n", "<leader>w", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" })
 | 
			
		||||
kmap("n", "qq", "<cmd>q<CR>", { noremap = true, silent = true, desc = "Exit" })
 | 
			
		||||
kmap("n", "<C-s>", "<cmd>wa<CR>", { noremap = true, silent = true, desc = "Save all files" })
 | 
			
		||||
kmap("n", "<leader>q", "<cmd>q<CR>", { noremap = true, silent = true, desc = "Exit" })
 | 
			
		||||
kmap("n", "<leader>vs", "<cmd>vsplit<CR>", { noremap = true, silent = true, desc = "Vertical split" })
 | 
			
		||||
-- }}}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -47,17 +47,16 @@ kmap("n", "<leader>tt", ":split<CR>:terminal<CR>:startinsert<CR>", { noremap = t
 | 
			
		|||
kmap("n", "<leader>e", vim.diagnostic.open_float, { noremap = true, silent = true, desc = "Show diagnostics" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "d[", vim.diagnostic.goto_prev, { noremap = true, silent = true, desc = "Previous diagnostic" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "d]", vim.diagnostic.goto_next, { noremap = true, silent = true, desc = "Next diagnostic" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "gD", vim.lsp.buf.declaration, { noremap = true, silent = true, desc = "Go to declaration" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "gd", vim.lsp.buf.definition, { noremap = true, silent = true, desc = "Go to definition" })
 | 
			
		||||
kmap("n", "<leader>D", vim.lsp.buf.type_definition, { noremap = true, silent = true, desc = "Type definition" })
 | 
			
		||||
kmap("n", "gr", vim.lsp.buf.references, { noremap = true, silent = true, desc = "Find references" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "K", vim.lsp.buf.hover, { noremap = true, silent = true, desc = "Show documentation" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "gi", vim.lsp.buf.implementation, { noremap = true, silent = true, desc = "Go to implementation" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "<C-k>", vim.lsp.buf.signature_help, { noremap = true, silent = true, desc = "Signature help" })
 | 
			
		||||
 | 
			
		||||
kmap(
 | 
			
		||||
| 
						 | 
				
			
			@ -78,11 +77,8 @@ kmap("n", "<leader>wl", function()
 | 
			
		|||
	print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
 | 
			
		||||
end, { noremap = true, silent = true, desc = "List workspace folders" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "<leader>D", vim.lsp.buf.type_definition, { noremap = true, silent = true, desc = "Type definition" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "<A-CR>", vim.lsp.buf.code_action, { noremap = true, silent = true, desc = "Code actions" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "gr", vim.lsp.buf.references, { noremap = true, silent = true, desc = "Find references" })
 | 
			
		||||
--kmap("n", "<A-CR>", vim.lsp.buf.code_action, { noremap = true, silent = true, desc = "Code actions" })
 | 
			
		||||
kmap("n", "<A-CR>", "<cmd>Lspsaga code_action<cr>", { noremap = true, silent = true, desc = "Code actions" })
 | 
			
		||||
 | 
			
		||||
kmap("n", "<F2>", vim.lsp.buf.rename, { noremap = true, silent = true, desc = "Rename symbol" })
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -7,11 +7,9 @@ local function config(_config)
 | 
			
		|||
		capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()),
 | 
			
		||||
	}, _config or {})
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- иницализация gopls LSP для Go
 | 
			
		||||
-- https://github.com/golang/tools/blob/master/gopls/doc/vim.md#neovim-install
 | 
			
		||||
lspconfig.gopls.setup(config({
 | 
			
		||||
	on_attach = on_attach,
 | 
			
		||||
	cmd = { "gopls", "serve" },
 | 
			
		||||
	filetypes = { "go", "go.mod" },
 | 
			
		||||
	root_dir = util.root_pattern("go.work", "go.mod", ".git"),
 | 
			
		||||
| 
						 | 
				
			
			@ -19,9 +17,15 @@ lspconfig.gopls.setup(config({
 | 
			
		|||
		gopls = {
 | 
			
		||||
			analyses = {
 | 
			
		||||
				unusedparams = true,
 | 
			
		||||
				shadow = true,
 | 
			
		||||
			},
 | 
			
		||||
			staticcheck = true,
 | 
			
		||||
			gofumpt = true,
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
}))
 | 
			
		||||
 | 
			
		||||
lspconfig.templ.setup(config({
 | 
			
		||||
	cmd = {"templ", "lsp"},
 | 
			
		||||
	filetypes = {"templ"},
 | 
			
		||||
	root_markers = { "go.work", "go.mod", ".git" },
 | 
			
		||||
}))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -32,12 +32,15 @@ local options = {
 | 
			
		|||
	scrolloff = 8,
 | 
			
		||||
	sidescrolloff = 8,
 | 
			
		||||
	syntax = "on",
 | 
			
		||||
	foldmethod = "marker",
 | 
			
		||||
	foldmethod = "expr",
 | 
			
		||||
	foldmarker = "{{{,}}}",
 | 
			
		||||
	--foldexpr = "nvim_treesitter#foldexpr()",
 | 
			
		||||
	foldlevelstart = 0,
 | 
			
		||||
	--foldexpr = "v:lua.vim.treesitter.foldexpr()",
 | 
			
		||||
	foldexpr = "nvim_treesitter#foldexpr()",
 | 
			
		||||
	foldlevelstart = 99,
 | 
			
		||||
	foldenable = true,
 | 
			
		||||
	scrolloff = 999,
 | 
			
		||||
	so = vim.fn.floor(vim.fn.winheight(0) / 2),
 | 
			
		||||
	guicursor = "n-v-c:block,i-ci-ve:ver25,r-cr:hor20,o:hor50,i:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,a:blinkwait700-blinkoff400-blinkon250-Cursor/lCursor,sm:block-blinkwait175-blinkoff150-blinkon175",
 | 
			
		||||
}
 | 
			
		||||
vim.opt.formatoptions:append({ r = true, o = true })
 | 
			
		||||
vim.opt.shortmess:append("c")
 | 
			
		||||
| 
						 | 
				
			
			@ -45,5 +48,11 @@ vim.opt.shortmess:append("c")
 | 
			
		|||
for k, v in pairs(options) do
 | 
			
		||||
	vim.opt[k] = v
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
vim.wo.foldmethod = "expr"
 | 
			
		||||
vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()"
 | 
			
		||||
vim.cmd("set whichwrap+=<,>,[,],h,l")
 | 
			
		||||
vim.filetype.add({
 | 
			
		||||
	extension = {
 | 
			
		||||
		templ = "templ",
 | 
			
		||||
	},
 | 
			
		||||
})
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,7 +1,11 @@
 | 
			
		|||
local plugins = {
 | 
			
		||||
require("lazy").setup({
 | 
			
		||||
	{ "nvim-lua/plenary.nvim" },
 | 
			
		||||
	{
 | 
			
		||||
		"ray-x/guihua.lua",
 | 
			
		||||
		build = "cd lua/fzy && make",
 | 
			
		||||
	},
 | 
			
		||||
	{ "neovim/nvim-lspconfig" },
 | 
			
		||||
	{ "Snyssfx/goerr-nvim" },
 | 
			
		||||
	-- { "Snyssfx/goerr-nvim" },
 | 
			
		||||
	{
 | 
			
		||||
		"lukas-reineke/indent-blankline.nvim",
 | 
			
		||||
		main = "ibl",
 | 
			
		||||
| 
						 | 
				
			
			@ -20,10 +24,61 @@ local plugins = {
 | 
			
		|||
	{
 | 
			
		||||
		"ray-x/lsp_signature.nvim",
 | 
			
		||||
		event = "VeryLazy",
 | 
			
		||||
		config = true,
 | 
			
		||||
		opts = {
 | 
			
		||||
			doc_lines = 1,
 | 
			
		||||
			max_height = 3,
 | 
			
		||||
			hint_prefix = "",
 | 
			
		||||
			hint_prefix = {
 | 
			
		||||
				above = "↙ ",
 | 
			
		||||
				current = "← ",
 | 
			
		||||
				below = "↖ ",
 | 
			
		||||
			},
 | 
			
		||||
			floating_window = false,
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"nvimdev/lspsaga.nvim",
 | 
			
		||||
		opts = {
 | 
			
		||||
			lightbulb = {
 | 
			
		||||
				enable = false,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		"karb94/neoscroll.nvim",
 | 
			
		||||
		opts = {
 | 
			
		||||
			stop_eof = false,
 | 
			
		||||
			respect_scrolloff = true,
 | 
			
		||||
			mappings = {
 | 
			
		||||
				"<C-u>",
 | 
			
		||||
				"<C-d>",
 | 
			
		||||
				"<C-b>",
 | 
			
		||||
				"<C-f>",
 | 
			
		||||
				"<C-y>",
 | 
			
		||||
				"<C-e>",
 | 
			
		||||
				"zt",
 | 
			
		||||
				"zz",
 | 
			
		||||
				"zb",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		keys = {
 | 
			
		||||
			{
 | 
			
		||||
				"<PageUp>",
 | 
			
		||||
				function()
 | 
			
		||||
					require("neoscroll").scroll(-vim.api.nvim_win_get_height(0) + 3, { duration = 150 })
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
			{
 | 
			
		||||
				"<PageDown>",
 | 
			
		||||
				function()
 | 
			
		||||
					require("neoscroll").scroll(vim.api.nvim_win_get_height(0) - 3, { duration = 150 })
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	require("plugins.autosave"),
 | 
			
		||||
	require("plugins.theme"),
 | 
			
		||||
	require("plugins.cmp"),
 | 
			
		||||
	require("plugins.onedark"),
 | 
			
		||||
	require("plugins.treesitter"),
 | 
			
		||||
	require("plugins.tree"),
 | 
			
		||||
	require("plugins.conform"),
 | 
			
		||||
| 
						 | 
				
			
			@ -34,9 +89,7 @@ local plugins = {
 | 
			
		|||
	require("plugins.lualine"),
 | 
			
		||||
	require("plugins.telescope"),
 | 
			
		||||
	require("plugins.columns"),
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
require("lazy").setup(plugins, {
 | 
			
		||||
}, {
 | 
			
		||||
	performance = {
 | 
			
		||||
		rtp = {
 | 
			
		||||
			disabled_plugins = {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										77
									
								
								nvim/lua/plugins/autosave.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										77
									
								
								nvim/lua/plugins/autosave.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,77 @@
 | 
			
		|||
return {
 | 
			
		||||
	"okuuva/auto-save.nvim",
 | 
			
		||||
	enabled = true,
 | 
			
		||||
	cmd = "ASToggle", -- optional for lazy loading on command
 | 
			
		||||
	event = { "InsertLeave", "TextChanged" }, -- optional for lazy loading on trigger events
 | 
			
		||||
	opts = {
 | 
			
		||||
		enabled = true, -- start auto-save when the plugin is loaded (i.e. when your package manager loads it)
 | 
			
		||||
		trigger_events = { -- See :h events
 | 
			
		||||
			-- -- vim events that trigger an immediate save
 | 
			
		||||
			-- -- I'm disabling this, as it's autosaving when I leave the buffer and
 | 
			
		||||
			-- -- that's autoformatting stuff if on insert mode and following a tutorial
 | 
			
		||||
			-- -- Re-enabling this to only save if NOT in insert mode in the condition below
 | 
			
		||||
			-- immediate_save = { nil },
 | 
			
		||||
			immediate_save = { "BufLeave", "FocusLost", "QuitPre", "VimSuspend" }, -- vim events that trigger an immediate save
 | 
			
		||||
			-- vim events that trigger a deferred save (saves after `debounce_delay`)
 | 
			
		||||
			defer_save = {
 | 
			
		||||
				"InsertLeave",
 | 
			
		||||
				"TextChanged",
 | 
			
		||||
				{ "User", pattern = "VisualLeave" },
 | 
			
		||||
				{ "User", pattern = "FlashJumpEnd" },
 | 
			
		||||
				{ "User", pattern = "SnacksInputLeave" },
 | 
			
		||||
				{ "User", pattern = "SnacksPickerInputLeave" },
 | 
			
		||||
			},
 | 
			
		||||
			cancel_deferred_save = {
 | 
			
		||||
				"InsertEnter",
 | 
			
		||||
				{ "User", pattern = "VisualEnter" },
 | 
			
		||||
				{ "User", pattern = "FlashJumpStart" },
 | 
			
		||||
				{ "User", pattern = "SnacksInputEnter" },
 | 
			
		||||
				{ "User", pattern = "SnacksPickerInputEnter" },
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		-- function that takes the buffer handle and determines whether to save the current buffer or not
 | 
			
		||||
		-- return true: if buffer is ok to be saved
 | 
			
		||||
		-- return false: if it's not ok to be saved
 | 
			
		||||
		-- if set to `nil` then no specific condition is applied
 | 
			
		||||
		condition = function(buf)
 | 
			
		||||
			-- Do not save when I'm in insert mode
 | 
			
		||||
			-- Do NOT ADD VISUAL MODE HERE or the cancel_deferred_save wont' work
 | 
			
		||||
			-- If I STAY in insert mode and switch to another app, like YouTube to
 | 
			
		||||
			-- take notes, the BufLeave or FocusLost immediate_save will be ignored
 | 
			
		||||
			-- and the save will not be triggered
 | 
			
		||||
			local mode = vim.fn.mode()
 | 
			
		||||
			if mode == "i" then
 | 
			
		||||
				return false
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			-- Disable auto-save for the harpoon plugin, otherwise it just opens and closes
 | 
			
		||||
			-- https://github.com/ThePrimeagen/harpoon/issues/434
 | 
			
		||||
			--
 | 
			
		||||
			-- don't save for `sql` file types
 | 
			
		||||
			-- I do this so when working with dadbod the file is not saved every time
 | 
			
		||||
			-- I make a change, and a SQL query executed
 | 
			
		||||
			-- Run `:set filetype?` on a dadbod query to make sure of the filetype
 | 
			
		||||
			local filetype = vim.bo[buf].filetype
 | 
			
		||||
			if filetype == "harpoon" or filetype == "mysql" then
 | 
			
		||||
				return false
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			-- Skip autosave if you're in an active snippet
 | 
			
		||||
			if require("luasnip").in_snippet() then
 | 
			
		||||
				return false
 | 
			
		||||
			end
 | 
			
		||||
 | 
			
		||||
			return true
 | 
			
		||||
		end,
 | 
			
		||||
		write_all_buffers = false, -- write all buffers when the current one meets `condition`
 | 
			
		||||
		-- Do not execute autocmds when saving
 | 
			
		||||
		-- If you set noautocmd = true, autosave won't trigger an auto format
 | 
			
		||||
		-- https://github.com/okuuva/auto-save.nvim/issues/55
 | 
			
		||||
		noautocmd = false,
 | 
			
		||||
		lockmarks = false, -- lock marks when saving, see `:h lockmarks` for more details
 | 
			
		||||
		-- delay after which a pending save is executed (default 1000)
 | 
			
		||||
		debounce_delay = 2000,
 | 
			
		||||
		-- log debug messages to 'auto-save.log' file in neovim cache directory, set to `true` to enable
 | 
			
		||||
		debug = false,
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -50,44 +50,46 @@ return {
 | 
			
		|||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	opts = {
 | 
			
		||||
		-- preselect = require("cmp").PreselectMode.None,
 | 
			
		||||
		experimental = {
 | 
			
		||||
			ghost_text = true,
 | 
			
		||||
		},
 | 
			
		||||
	config = function()
 | 
			
		||||
		require("cmp").setup({
 | 
			
		||||
			preselect = require("cmp").PreselectMode.None,
 | 
			
		||||
			experimental = {
 | 
			
		||||
				ghost_text = false,
 | 
			
		||||
			},
 | 
			
		||||
 | 
			
		||||
		confirmation = {
 | 
			
		||||
			default_behavior = require("cmp").ConfirmBehavior.Replace,
 | 
			
		||||
		},
 | 
			
		||||
		completion = {
 | 
			
		||||
			completeopt = "menu,menuone,noinsert,noselect",
 | 
			
		||||
			keyword_length = 2,
 | 
			
		||||
		},
 | 
			
		||||
		mapping = require("cmp").mapping.preset.insert({
 | 
			
		||||
			["<C-b>"] = require("cmp").mapping.scroll_docs(-4),
 | 
			
		||||
			["<C-f>"] = require("cmp").mapping.scroll_docs(4),
 | 
			
		||||
			["<C-Space>"] = require("cmp").mapping.complete(),
 | 
			
		||||
			["<C-e>"] = require("cmp").mapping.abort(),
 | 
			
		||||
			["<CR>"] = require("cmp").mapping.confirm({ select = false }),
 | 
			
		||||
			["<Right>"] = require("cmp").mapping.confirm({ select = true }),
 | 
			
		||||
		}),
 | 
			
		||||
		snippet = {
 | 
			
		||||
			expand = function(args)
 | 
			
		||||
				require("luasnip").lsp_expand(args.body)
 | 
			
		||||
			end,
 | 
			
		||||
		},
 | 
			
		||||
		formatting = {
 | 
			
		||||
			format = function(entry, vim_item)
 | 
			
		||||
				vim_item.menu = source_mapping[entry.source.name] or "[Unknown]"
 | 
			
		||||
				return vim_item
 | 
			
		||||
			end,
 | 
			
		||||
		},
 | 
			
		||||
		sources = require("cmp").config.sources({
 | 
			
		||||
			{ name = "nvim_lsp", priority = 1000 },
 | 
			
		||||
			{ name = "luasnip", priority = 750 },
 | 
			
		||||
			{ name = "path", priority = 500 },
 | 
			
		||||
		}, {
 | 
			
		||||
			{ name = "buffer" },
 | 
			
		||||
		}),
 | 
			
		||||
	},
 | 
			
		||||
			confirmation = {
 | 
			
		||||
				default_behavior = require("cmp").ConfirmBehavior.Replace,
 | 
			
		||||
			},
 | 
			
		||||
			completion = {
 | 
			
		||||
				completeopt = "menu,menuone,noinsert,noselect",
 | 
			
		||||
				keyword_length = 2,
 | 
			
		||||
			},
 | 
			
		||||
			mapping = require("cmp").mapping.preset.insert({
 | 
			
		||||
				["<C-b>"] = require("cmp").mapping.scroll_docs(-4),
 | 
			
		||||
				["<C-f>"] = require("cmp").mapping.scroll_docs(4),
 | 
			
		||||
				["<C-Space>"] = require("cmp").mapping.complete(),
 | 
			
		||||
				["<C-e>"] = require("cmp").mapping.abort(),
 | 
			
		||||
				["<CR>"] = require("cmp").mapping.confirm({ select = false }),
 | 
			
		||||
				["<C-y>"] = require("cmp").mapping.confirm({ select = true }),
 | 
			
		||||
			}),
 | 
			
		||||
			snippet = {
 | 
			
		||||
				expand = function(args)
 | 
			
		||||
					require("luasnip").lsp_expand(args.body)
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
			formatting = {
 | 
			
		||||
				format = function(entry, vim_item)
 | 
			
		||||
					vim_item.menu = source_mapping[entry.source.name] or "[Unknown]"
 | 
			
		||||
					return vim_item
 | 
			
		||||
				end,
 | 
			
		||||
			},
 | 
			
		||||
			sources = require("cmp").config.sources({
 | 
			
		||||
				{ name = "nvim_lsp", priority = 1000 },
 | 
			
		||||
				{ name = "luasnip", priority = 750 },
 | 
			
		||||
				{ name = "path", priority = 500 },
 | 
			
		||||
			}, {
 | 
			
		||||
				{ name = "buffer" },
 | 
			
		||||
			}),
 | 
			
		||||
		})
 | 
			
		||||
	end,
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -15,6 +15,7 @@ return {
 | 
			
		|||
			lua = { "stylua" },
 | 
			
		||||
			python = { "isort", "black" },
 | 
			
		||||
			go = { "gofmt" },
 | 
			
		||||
			templ = { "templ" },
 | 
			
		||||
		},
 | 
			
		||||
		format_on_save = {
 | 
			
		||||
			lsp_fallback = true,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,7 +3,7 @@ return {
 | 
			
		|||
	opts = {
 | 
			
		||||
		options = {
 | 
			
		||||
			icons_enabled = true,
 | 
			
		||||
			theme = "auto",
 | 
			
		||||
			theme = "onedark",
 | 
			
		||||
			component_separators = { left = "", right = "" },
 | 
			
		||||
			section_separators = { left = "", right = "" },
 | 
			
		||||
			disabled_filetypes = {
 | 
			
		||||
| 
						 | 
				
			
			@ -23,9 +23,9 @@ return {
 | 
			
		|||
			lualine_a = { "mode" },
 | 
			
		||||
			lualine_b = { "branch", "diff", "diagnostics" },
 | 
			
		||||
			lualine_c = { "filename" },
 | 
			
		||||
			lualine_x = { "encoding", "fileformat", "filetype" },
 | 
			
		||||
			lualine_y = { "progress" },
 | 
			
		||||
			lualine_z = { "location" },
 | 
			
		||||
			lualine_x = { "filetype" },
 | 
			
		||||
			lualine_y = { "progress", "location" },
 | 
			
		||||
			lualine_z = { "lsp_status", "os.date('%H:%M')" },
 | 
			
		||||
		},
 | 
			
		||||
		inactive_sections = {
 | 
			
		||||
			lualine_a = {},
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,33 +0,0 @@
 | 
			
		|||
return {
 | 
			
		||||
	"navarasu/onedark.nvim",
 | 
			
		||||
	opts = {
 | 
			
		||||
		style = "darker",
 | 
			
		||||
		transparent = false, -- Show/hide background
 | 
			
		||||
		term_colors = true, -- Change terminal color as per the selected theme style
 | 
			
		||||
		ending_tildes = true, -- Show the end-of-buffer tildes. By default they are hidden
 | 
			
		||||
		cmp_itemkind_reverse = false, -- reverse item kind highlights in cmp menu
 | 
			
		||||
		toggle_style_key = nil, -- keybind to toggle theme style. Leave it nil to disable it, or set it to a string, for example "<leader>ts"
 | 
			
		||||
		toggle_style_list = { "dark", "darker", "cool", "deep", "warm", "warmer", "light" }, -- List of styles to toggle between
 | 
			
		||||
 | 
			
		||||
		code_style = {
 | 
			
		||||
			comments = "italic",
 | 
			
		||||
			keywords = "none",
 | 
			
		||||
			functions = "none",
 | 
			
		||||
			strings = "none",
 | 
			
		||||
			variables = "none",
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		lualine = {
 | 
			
		||||
			transparent = false, -- lualine center bar transparency
 | 
			
		||||
		},
 | 
			
		||||
 | 
			
		||||
		colors = {}, -- Override default colors
 | 
			
		||||
		highlights = {}, -- Override highlight groups
 | 
			
		||||
 | 
			
		||||
		diagnostics = {
 | 
			
		||||
			darker = true, -- darker colors for diagnostic
 | 
			
		||||
			undercurl = true, -- use undercurl instead of underline for diagnostics
 | 
			
		||||
			background = true, -- use background color for virtual text
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										21
									
								
								nvim/lua/plugins/theme.lua
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								nvim/lua/plugins/theme.lua
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,21 @@
 | 
			
		|||
return {
 | 
			
		||||
	"navarasu/onedark.nvim",
 | 
			
		||||
	priority = 1000, -- make sure to load this before all the other start plugins
 | 
			
		||||
	config = function()
 | 
			
		||||
		require("onedark").setup({
 | 
			
		||||
			style = "darker",
 | 
			
		||||
			colors = {
 | 
			
		||||
				bright_orange = "#ff8800", -- define a new color
 | 
			
		||||
			},
 | 
			
		||||
			highlights = {
 | 
			
		||||
				-- ["@lsp.type.keyword"] = { fg = "$green", fmt = "bold,underline" },
 | 
			
		||||
				-- ["@lsp.type.property"] = { fg = "$bright_orange", bg = "#00ff00", fmt = "bold" },
 | 
			
		||||
				-- ["@lsp.type.function"] = { fg = "#0000ff", sp = "$cyan", fmt = "underline,italic" },
 | 
			
		||||
				-- ["@lsp.type.method"] = { link = "@function" },
 | 
			
		||||
				-- To add language specific config
 | 
			
		||||
				-- ["@lsp.type.variable.go"] = { fg = "none" },
 | 
			
		||||
			},
 | 
			
		||||
		})
 | 
			
		||||
		require("onedark").load()
 | 
			
		||||
	end,
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -2,56 +2,42 @@ return {
 | 
			
		|||
	"nvim-treesitter/nvim-treesitter",
 | 
			
		||||
	build = ":TSUpdate",
 | 
			
		||||
	opts = {
 | 
			
		||||
		highlight = { enable = true },
 | 
			
		||||
		ensure_installed = {
 | 
			
		||||
			"c",
 | 
			
		||||
			"lua",
 | 
			
		||||
			"python",
 | 
			
		||||
			"bash",
 | 
			
		||||
			"go",
 | 
			
		||||
			"html",
 | 
			
		||||
			"css",
 | 
			
		||||
			"javascript",
 | 
			
		||||
			"typescript",
 | 
			
		||||
			"git_config",
 | 
			
		||||
			"git_rebase",
 | 
			
		||||
			"gitattributes",
 | 
			
		||||
			"gitcommit",
 | 
			
		||||
			"gitignore",
 | 
			
		||||
			"gomod",
 | 
			
		||||
			"gosum",
 | 
			
		||||
			"gotmpl",
 | 
			
		||||
			"gowork",
 | 
			
		||||
			"hjson",
 | 
			
		||||
			"ini",
 | 
			
		||||
			"json",
 | 
			
		||||
			"json5",
 | 
			
		||||
			"jsonnet",
 | 
			
		||||
			"latex",
 | 
			
		||||
			"make",
 | 
			
		||||
			"markdown",
 | 
			
		||||
			"markdown_inline",
 | 
			
		||||
			"nginx",
 | 
			
		||||
			"proto",
 | 
			
		||||
			"rust",
 | 
			
		||||
			"templ",
 | 
			
		||||
			"todotxt",
 | 
			
		||||
			"toml",
 | 
			
		||||
			"tsx",
 | 
			
		||||
			"typescript",
 | 
			
		||||
			"vim",
 | 
			
		||||
			"vimdoc",
 | 
			
		||||
			"xml",
 | 
			
		||||
			"yaml",
 | 
			
		||||
			"sql",
 | 
			
		||||
			"ssh_config",
 | 
			
		||||
		highlight = {
 | 
			
		||||
			enable = true,
 | 
			
		||||
			additional_vim_regex_highlighting = false,
 | 
			
		||||
		},
 | 
			
		||||
		ensure_installed = "all",
 | 
			
		||||
		ignore_install = { "gdhsader", "phpdoc" },
 | 
			
		||||
		indent = { enable = true },
 | 
			
		||||
		auto_install = true,
 | 
			
		||||
		sync_install = false,
 | 
			
		||||
		textobjects = { select = { enable = true, lookahead = true } },
 | 
			
		||||
		sync_install = true,
 | 
			
		||||
		incremental_selection = {
 | 
			
		||||
			enable = true,
 | 
			
		||||
			keymaps = {
 | 
			
		||||
				init_selection = "<C-space>",
 | 
			
		||||
				node_incremental = "<C-space>",
 | 
			
		||||
				scope_incremental = false,
 | 
			
		||||
				node_decremental = "<bs>",
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		textobjects = {
 | 
			
		||||
			select = { enable = true, lookahead = true },
 | 
			
		||||
			move = {
 | 
			
		||||
				enable = true,
 | 
			
		||||
				goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer", ["]a"] = "@parameter.inner" },
 | 
			
		||||
				goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer", ["]A"] = "@parameter.inner" },
 | 
			
		||||
				goto_previous_start = {
 | 
			
		||||
					["[f"] = "@function.outer",
 | 
			
		||||
					["[c"] = "@class.outer",
 | 
			
		||||
					["[a"] = "@parameter.inner",
 | 
			
		||||
				},
 | 
			
		||||
				goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer", ["[A"] = "@parameter.inner" },
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	build = function()
 | 
			
		||||
		require("nvim-treesitter.install").update({ with_sync = true })()
 | 
			
		||||
	end,
 | 
			
		||||
	dependencies = {
 | 
			
		||||
		{ "nvim-treesitter/nvim-treesitter-textobjects" },
 | 
			
		||||
		{
 | 
			
		||||
| 
						 | 
				
			
			@ -62,5 +48,6 @@ return {
 | 
			
		|||
				line_numbers = true,
 | 
			
		||||
			},
 | 
			
		||||
		},
 | 
			
		||||
		{ "windwp/nvim-ts-autotag" },
 | 
			
		||||
	},
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue