diff options
| author | 2025-05-13 10:07:17 +0300 | |
|---|---|---|
| committer | 2025-05-13 10:07:17 +0300 | |
| commit | e9a2f811b7d030cb8701bd8459fd5c842a521eff (patch) | |
| tree | 2c59e183408f6d814bdb32453cae84f03f8bf88b /nvim/lua/plugins | |
| parent | Поправил тему zsh (diff) | |
| download | dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.tar.gz dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.tar.bz2 dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.tar.xz dotfiles-e9a2f811b7d030cb8701bd8459fd5c842a521eff.zip | |
Правки nvim конфига
Diffstat (limited to '')
| -rw-r--r-- | nvim/lua/plugins.lua | 67 | ||||
| -rw-r--r-- | nvim/lua/plugins/autosave.lua | 77 | ||||
| -rw-r--r-- | nvim/lua/plugins/cmp.lua | 80 | ||||
| -rw-r--r-- | nvim/lua/plugins/conform.lua | 1 | ||||
| -rw-r--r-- | nvim/lua/plugins/lualine.lua | 8 | ||||
| -rw-r--r-- | nvim/lua/plugins/onedark.lua | 33 | ||||
| -rw-r--r-- | nvim/lua/plugins/theme.lua | 21 | ||||
| -rw-r--r-- | nvim/lua/plugins/treesitter.lua | 77 |
8 files changed, 236 insertions, 128 deletions
diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index 4b0b605..0f46ea6 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -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 = { diff --git a/nvim/lua/plugins/autosave.lua b/nvim/lua/plugins/autosave.lua new file mode 100644 index 0000000..9cbcd83 --- /dev/null +++ b/nvim/lua/plugins/autosave.lua @@ -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, + }, +} diff --git a/nvim/lua/plugins/cmp.lua b/nvim/lua/plugins/cmp.lua index 0a7cffc..7457d2f 100644 --- a/nvim/lua/plugins/cmp.lua +++ b/nvim/lua/plugins/cmp.lua @@ -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, } diff --git a/nvim/lua/plugins/conform.lua b/nvim/lua/plugins/conform.lua index ea0fcf0..3204d2d 100644 --- a/nvim/lua/plugins/conform.lua +++ b/nvim/lua/plugins/conform.lua @@ -15,6 +15,7 @@ return { lua = { "stylua" }, python = { "isort", "black" }, go = { "gofmt" }, + templ = { "templ" }, }, format_on_save = { lsp_fallback = true, diff --git a/nvim/lua/plugins/lualine.lua b/nvim/lua/plugins/lualine.lua index 3be9d19..19bcb8e 100644 --- a/nvim/lua/plugins/lualine.lua +++ b/nvim/lua/plugins/lualine.lua @@ -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 = {}, diff --git a/nvim/lua/plugins/onedark.lua b/nvim/lua/plugins/onedark.lua deleted file mode 100644 index f4c4aca..0000000 --- a/nvim/lua/plugins/onedark.lua +++ /dev/null @@ -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 - }, - }, -} diff --git a/nvim/lua/plugins/theme.lua b/nvim/lua/plugins/theme.lua new file mode 100644 index 0000000..72a6f81 --- /dev/null +++ b/nvim/lua/plugins/theme.lua @@ -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, +} diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index f6127d7..08d05e9 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -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" }, }, } |
