Правки nvim конфига
This commit is contained in:
parent
7e3d15704b
commit
e9a2f811b7
15 changed files with 313 additions and 166 deletions
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