From 8082bd0f1e87228a6ade162425a7570d93a05f06 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 20:36:04 +0300 Subject: [PATCH 01/41] Start config revamp based on neovim docs --- DESCRIPTION.md | 2 - Dockerfile | 37 ------ Dockerfile_old | 26 ----- README.md | 53 +-------- archived/nvim-tree.lua | 40 ------- ftplugin/go.lua | 1 + init.lua | 38 +++++- lua/{t0xa/plugins => custom}/oil.lua | 10 +- lua/custom/plugins/oil.lua | 8 ++ lua/t0xa/core/keybindings.lua | 13 --- lua/t0xa/core/options.lua | 51 -------- lua/t0xa/lazy.lua | 22 ---- lua/t0xa/plugins/autopairs.lua | 31 ----- lua/t0xa/plugins/blame.lua | 6 - lua/t0xa/plugins/colorscheme.lua | 24 ---- lua/t0xa/plugins/comment.lua | 19 --- lua/t0xa/plugins/dadbod.lua | 5 - lua/t0xa/plugins/dressing.lua | 4 - lua/t0xa/plugins/lsp/lspconfig.lua | 147 ------------------------ lua/t0xa/plugins/lsp/mason.lua | 49 -------- lua/t0xa/plugins/lualine.lua | 24 ---- lua/t0xa/plugins/neogen.lua | 15 --- lua/t0xa/plugins/none-ls.lua | 18 --- lua/t0xa/plugins/nvim-cmp.lua | 90 --------------- lua/t0xa/plugins/nvim-tree.lua | 43 ------- lua/t0xa/plugins/obsidian.lua | 32 ------ lua/t0xa/plugins/plenary.lua | 3 - lua/t0xa/plugins/rust-tools.lua | 3 - lua/t0xa/plugins/telescope.lua | 41 ------- lua/t0xa/plugins/todo-comments.lua | 21 ---- lua/t0xa/plugins/treesitter.lua | 66 ----------- lua/t0xa/plugins/trouble.lua | 37 ------ lua/t0xa/plugins/vim-tmux-navigator.lua | 17 --- lua/t0xa/plugins/which-key.lua | 19 --- snippets/go.json | 17 --- snippets/package.json | 20 ---- snippets/python.json | 36 ------ 37 files changed, 47 insertions(+), 1041 deletions(-) delete mode 100644 Dockerfile delete mode 100644 Dockerfile_old delete mode 100644 archived/nvim-tree.lua create mode 100644 ftplugin/go.lua rename lua/{t0xa/plugins => custom}/oil.lua (76%) create mode 100644 lua/custom/plugins/oil.lua delete mode 100644 lua/t0xa/core/keybindings.lua delete mode 100644 lua/t0xa/core/options.lua delete mode 100644 lua/t0xa/lazy.lua delete mode 100644 lua/t0xa/plugins/autopairs.lua delete mode 100644 lua/t0xa/plugins/blame.lua delete mode 100644 lua/t0xa/plugins/colorscheme.lua delete mode 100644 lua/t0xa/plugins/comment.lua delete mode 100644 lua/t0xa/plugins/dadbod.lua delete mode 100644 lua/t0xa/plugins/dressing.lua delete mode 100644 lua/t0xa/plugins/lsp/lspconfig.lua delete mode 100644 lua/t0xa/plugins/lsp/mason.lua delete mode 100644 lua/t0xa/plugins/lualine.lua delete mode 100644 lua/t0xa/plugins/neogen.lua delete mode 100644 lua/t0xa/plugins/none-ls.lua delete mode 100644 lua/t0xa/plugins/nvim-cmp.lua delete mode 100644 lua/t0xa/plugins/nvim-tree.lua delete mode 100644 lua/t0xa/plugins/obsidian.lua delete mode 100644 lua/t0xa/plugins/plenary.lua delete mode 100644 lua/t0xa/plugins/rust-tools.lua delete mode 100644 lua/t0xa/plugins/telescope.lua delete mode 100644 lua/t0xa/plugins/todo-comments.lua delete mode 100644 lua/t0xa/plugins/treesitter.lua delete mode 100644 lua/t0xa/plugins/trouble.lua delete mode 100644 lua/t0xa/plugins/vim-tmux-navigator.lua delete mode 100644 lua/t0xa/plugins/which-key.lua delete mode 100644 snippets/go.json delete mode 100644 snippets/package.json delete mode 100644 snippets/python.json diff --git a/DESCRIPTION.md b/DESCRIPTION.md index b0d8f92..e69de29 100644 --- a/DESCRIPTION.md +++ b/DESCRIPTION.md @@ -1,2 +0,0 @@ -# Useful links -- [neovim stup guide](https://www.youtube.com/watch?v=6pAG3BHurdM) diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 5d86dda..0000000 --- a/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -FROM ubuntu:latest - -# Install build tools and nvim deps -RUN apt-get update && apt-get install -y --no-install-recommends \ - cmake \ - gettext \ - unzip \ - git \ - build-essential \ - curl \ - nodejs \ - npm \ - fzf \ - golang-go \ - python3 \ - python3-pip \ - python3-venv \ - ripgrep - -# Clone neovim repo -RUN git clone --depth 1 --branch v0.10.1 https://github.com/neovim/neovim.git -# Build neovim -RUN cd neovim && CMAKE_BUILD_TYPE=Release && make install - -# Install rust -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -y | sh - -# Create user -RUN useradd -m nvim_playground -USER nvim_playground - -# Copy config to user folders -RUN mkdir -p /home/nvim_playground/.config/nvim -WORKDIR /home/nvim_playground/.config/nvim -COPY --chown=nvim_playground:nvim_playground . . - -USER nvim_playground diff --git a/Dockerfile_old b/Dockerfile_old deleted file mode 100644 index a28923a..0000000 --- a/Dockerfile_old +++ /dev/null @@ -1,26 +0,0 @@ -FROM ubuntu:latest - -LABEL maintainer="pro100ton@gmail.com" - -RUN apt-get update && apt-get install -y \ - build-essential \ - curl \ - neovim \ - git \ - nodejs \ - npm \ - fzf \ - golang-go \ - python3 \ - python3-pip \ - python3-venv \ - unzip \ - ripgrep -RUN useradd -m nvim_playground - -USER nvim_playground - -RUN mkdir /home/nvim_playground/.config -RUN mkdir /home/nvim_playground/.config/nvim -WORKDIR /home/nvim_playground/.config/nvim -COPY . . diff --git a/README.md b/README.md index 19683ef..6fb4778 100644 --- a/README.md +++ b/README.md @@ -1,52 +1 @@ -# Installation -## obsidian.nvim -Чтобы правильно работал плагин для obsidian'a - необходимо установить переменную окружения `OBSIDIAN_NOTES_PATH`, которая будет указывать путь до папки, где лежат документы obsidian. - -Код, в котором это используется: - -path: `lua/t0xa/plugins/obsidian.lua` -code -```lua -... -workspaces = { - { - name = "personal", - path = os.getenv("OBSIDIAN_NOTES_PATH"), - }, -}, -... -``` - - -# File structure -``` -. -├── Dockerfile -├── README.md -├── init.lua -└── lua - └── t0xa - ├── core - │   └── options.lua - └── plugins - └── lazy.lua -``` - -## init.lua -Файл, в который "смотрит" neovim при [старте](https://neovim.io/doc/user/starting.html#initialization). - -## t0xa -Вместо того, чтобы использовать обращение к файлам настройки напрямую - используется данная -папка. -Можно обходиться без нее, однако для избегания конфликтов нейминга решил что буду использовать -так. -## core -Тут хранятся базовые настройки для neovim -## plugins -Папка для хранения и настроек плагинов для neovim - -# Команда для запуска контейнеров - -``` -docker build -t nvim:nvim . && docker run -it --user nvim_playground nvim:nvim -``` +# Config refactor (v2.0) diff --git a/archived/nvim-tree.lua b/archived/nvim-tree.lua deleted file mode 100644 index e091d72..0000000 --- a/archived/nvim-tree.lua +++ /dev/null @@ -1,40 +0,0 @@ -return { - "nvim-tree/nvim-tree.lua", - dependencies = "nvim-tree/nvim-web-devicons", - config = function() - local nvimtree = require("nvim-tree") - -- recommended settings from nvim-tree documentation - vim.g.loaded_netrw = 1 - vim.g.loaded_netrwPlugin = 1 - - nvimtree.setup({ - view = { - -- width = 35, - adaptive_size = true, - relativenumber = true, - }, - -- disable window_picker for explorer to work well with window splits - actions = { - open_file = { - window_picker = { - enable = true, - }, - }, - }, - -- Custom list of vim regex for names that will not be shown - filters = { - custom = { ".DS_Store" }, - }, - -- Show files ignored by git - git = { - ignore = false, - }, - }) - - -- set nvim-tree keypmaps - local keymap = vim.keymap - keymap.set('n', 'nt', ':NvimTreeToggle', {desc = "Toggle file explorer"}) - keymap.set('n', 'nf', ':NvimTreeFindFileToggle', {desc = "Toggle file explorer on current file"}) - - end -} diff --git a/ftplugin/go.lua b/ftplugin/go.lua new file mode 100644 index 0000000..1473193 --- /dev/null +++ b/ftplugin/go.lua @@ -0,0 +1 @@ +print("Hello from golang file") diff --git a/init.lua b/init.lua index a06767a..a7a4306 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,34 @@ --- Omitting `lua` directory, because neovim autmaticaly serching in it -require("t0xa.core.options") -require("t0xa.core.keybindings") -require("t0xa.lazy") +-- Bootstrap lazy.nvim +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not (vim.uv or vim.loop).fs_stat(lazypath) then + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end +end +vim.opt.rtp:prepend(lazypath) + +-- Making leader () key to space +vim.g.mapleader = " " +-- Making local leader () key to backslash +vim.g.maplocalleader = "\\" + +-- Setup lazy.nvim +require("lazy").setup({ + spec = { + -- import your plugins + { import = "custom/plugins" }, + }, + -- Configure any other settings here. See the documentation for more details. + -- colorscheme that will be used when installing plugins. + install = { colorscheme = { "gruvbox-material" } }, + -- automatically check for plugin updates + checker = { enabled = false }, +}) diff --git a/lua/t0xa/plugins/oil.lua b/lua/custom/oil.lua similarity index 76% rename from lua/t0xa/plugins/oil.lua rename to lua/custom/oil.lua index af70737..0b43a33 100644 --- a/lua/t0xa/plugins/oil.lua +++ b/lua/custom/oil.lua @@ -1,7 +1,4 @@ -return { - "stevearc/oil.nvim", - ---@module 'oil' - ---@type oil.SetupOpts +require("oil").setup{ opts = { keymaps = { ["g?"] = "actions.show_help", @@ -25,7 +22,6 @@ return { show_hidden = true, }, }, - -- Optional dependencies - dependencies = { { "echasnovski/mini.icons", opts = {} } }, - -- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if prefer nvim-web-devicons + -- Open parent directory in current window + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }), } diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 0000000..96156df --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,8 @@ +return { + "stevearc/oil.nvim", + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + config = function() + require "custom/oil" + end, +} + diff --git a/lua/t0xa/core/keybindings.lua b/lua/t0xa/core/keybindings.lua deleted file mode 100644 index 55dfcb9..0000000 --- a/lua/t0xa/core/keybindings.lua +++ /dev/null @@ -1,13 +0,0 @@ --- Obsidian-related keybinds -vim.keymap.set("n", "oit", "ObsidianTemplate", { silent = true, noremap = true, desc="Obsidian: insert template" }) -vim.keymap.set("n", "oo", "ObsidianQuickSwitch", { silent = true, noremap = true, desc="Obsidian: open file" }) -vim.keymap.set("n", "opi", "ObsidianPasteImg", { silent = true, noremap = true, desc="Obsidian: paste image" }) -vim.keymap.set("n", "or", "ObsidianRename", { silent = true, noremap = true, desc="Obsidian: rename file" }) -vim.keymap.set("n", "ol", "ObsidianToggleCheckbox", { silent = true, noremap = true, desc="Obsidian: toggle checkbox" }) -vim.keymap.set("n", "on", "ObsidianNew", { silent = true, noremap = true, desc="Obsidian: new file" }) -vim.keymap.set("n", "otoc", "ObsidianTOC", { silent = true, noremap = true, desc="Obsidian: open TOC" }) -vim.keymap.set("n", "ofl", "ObsidianFollowLink", { silent = true, noremap = true, desc="Obsidian: follow link" }) --- Oil keybinds -vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) - -- Easy escape from terminal -vim.keymap.set("t", "", "") diff --git a/lua/t0xa/core/options.lua b/lua/t0xa/core/options.lua deleted file mode 100644 index 2511376..0000000 --- a/lua/t0xa/core/options.lua +++ /dev/null @@ -1,51 +0,0 @@ -local opt = vim.opt -- Shorcut to scip writing vim.opt.* in settings beneath - --- enable line number and relative line number -opt.number = true -- This will show the line number cursor is currently standing -opt.relativenumber = true -- This will enable relative numbers on the left side - --- tabs & indentation -opt.shiftwidth = 2 -- Set spaces for tabs == 2 -opt.tabstop = 2 -- Set spaces for indent with == 2 -opt.expandtab = true -- use number of spaces to insert a -opt.softtabstop = 2 - --- search settings -opt.ignorecase = true -- ignore case when searching -opt.smartcase = true -- If mixing cases while searching = you want case-sensitive search - --- Cursor line setting -opt.cursorline = true - --- Turn on termguicolors for colorschemes --- (Have to use true color terminal to see theese setting work) -opt.termguicolors = true -opt.background = "dark" -- colorschemes that can be light or dark will be made dark -opt.signcolumn = "yes" -- show sigh columns so that text doesn't shift - --- backspace setting -opt.backspace = "indent,eol,start" -- allow backspace on indent, end of line or insert mode start position - --- clipboard -opt.clipboard:append("unnamedplus") -- config to set up clipboard as default register - --- split windows settings -opt.splitright = true -- split vertical window to the right -opt.splitbelow = true -- split horizontal window to the bottom - --- disable swap files creation -opt.swapfile = false - --- Add line at 88 symbols -opt.colorcolumn = "120" - --- Obsidian setting fot concealing charachters -opt.conceallevel = 0 - --- Enbale folding column -opt.foldmethod = "indent" -opt.foldcolumn = "1" -opt.foldlevelstart = 10 - --- Live buffer editing -opt.inccommand = "split" diff --git a/lua/t0xa/lazy.lua b/lua/t0xa/lazy.lua deleted file mode 100644 index 46b5139..0000000 --- a/lua/t0xa/lazy.lua +++ /dev/null @@ -1,22 +0,0 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not (vim.uv or vim.loop).fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "https://github.com/folke/lazy.nvim.git", - "--branch=stable", -- latest stable release - lazypath, - }) -end -vim.opt.rtp:prepend(lazypath) - --- Initializing `lazy` lib and -require("lazy").setup({ - { - import = "t0xa.plugins", - }, - { - import = "t0xa.plugins.lsp", - }, -}) diff --git a/lua/t0xa/plugins/autopairs.lua b/lua/t0xa/plugins/autopairs.lua deleted file mode 100644 index e22b7db..0000000 --- a/lua/t0xa/plugins/autopairs.lua +++ /dev/null @@ -1,31 +0,0 @@ -return { - "windwp/nvim-autopairs", - event = { "InsertEnter" }, - dependencies = { - "hrsh7th/nvim-cmp", - }, - config = function() - -- import nvim-autopairs - local autopairs = require("nvim-autopairs") - - -- configure autopairs - autopairs.setup({ - check_ts = true, -- enable treesitter - ts_config = { - lua = { "string" }, -- don't add pairs in lua string treesitter nodes - javascript = { "template_string" }, -- don't add pairs in javscript template_string treesitter nodes - java = false, -- don't check treesitter on java - }, - }) - - -- import nvim-autopairs completion functionality - local cmp_autopairs = require("nvim-autopairs.completion.cmp") - - -- import nvim-cmp plugin (completions plugin) - local cmp = require("cmp") - - -- make autopairs and completion work together - cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done()) - end, -} - diff --git a/lua/t0xa/plugins/blame.lua b/lua/t0xa/plugins/blame.lua deleted file mode 100644 index b198696..0000000 --- a/lua/t0xa/plugins/blame.lua +++ /dev/null @@ -1,6 +0,0 @@ -return { - "FabijanZulj/blame.nvim", - config = function() - require("blame").setup() - end -} diff --git a/lua/t0xa/plugins/colorscheme.lua b/lua/t0xa/plugins/colorscheme.lua deleted file mode 100644 index d1ebd9c..0000000 --- a/lua/t0xa/plugins/colorscheme.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - "folke/tokyonight.nvim", - dependencies = { - "ellisonleao/gruvbox.nvim", - -- "morphez/gruvbox.nvim", - "sainnhe/everforest", - "sainnhe/gruvbox-material", - "rebelot/kanagawa.nvim", - "catppuccin/nvim", - "folke/tokyonight.nvim", - "luisiacc/gruvbox-baby", - }, - lazy = false, - priority = 1000, - config = function() - -- vim.cmd.colorscheme("tokyonight-night") - -- vim.cmd.colorscheme("gruvbox") - -- vim.cmd.colorscheme("gruvbox-baby") - vim.g.gruvbox_material_background = 'hard' - vim.g.gruvbox_material_enable_italic = true - vim.cmd.colorscheme("gruvbox-material") - -- vim.cmd.colorscheme("catppuccin-mocha") - end, -} diff --git a/lua/t0xa/plugins/comment.lua b/lua/t0xa/plugins/comment.lua deleted file mode 100644 index ecc93c4..0000000 --- a/lua/t0xa/plugins/comment.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - "numToStr/Comment.nvim", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - "JoosepAlviste/nvim-ts-context-commentstring", - }, - config = function() - -- import comment plugin safely - local comment = require("Comment") - - local ts_context_commentstring = require("ts_context_commentstring.integrations.comment_nvim") - - -- enable comment - comment.setup({ - -- for commenting tsx, jsx, svelte, html files - pre_hook = ts_context_commentstring.create_pre_hook(), - }) - end, -} diff --git a/lua/t0xa/plugins/dadbod.lua b/lua/t0xa/plugins/dadbod.lua deleted file mode 100644 index dc5d76b..0000000 --- a/lua/t0xa/plugins/dadbod.lua +++ /dev/null @@ -1,5 +0,0 @@ -return { - "tpope/vim-dadbod", - "kristijanhusak/vim-dadbod-completion", - "kristijanhusak/vim-dadbod-ui", -} diff --git a/lua/t0xa/plugins/dressing.lua b/lua/t0xa/plugins/dressing.lua deleted file mode 100644 index feadb27..0000000 --- a/lua/t0xa/plugins/dressing.lua +++ /dev/null @@ -1,4 +0,0 @@ -return { - "stevearc/dressing.nvim", - event = "VeryLazy" -} diff --git a/lua/t0xa/plugins/lsp/lspconfig.lua b/lua/t0xa/plugins/lsp/lspconfig.lua deleted file mode 100644 index 13e1ccd..0000000 --- a/lua/t0xa/plugins/lsp/lspconfig.lua +++ /dev/null @@ -1,147 +0,0 @@ -return { - "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { - "hrsh7th/cmp-nvim-lsp", - -- Some additional QOL impovements like rename imports when file is renamed - { "antosha417/nvim-lsp-file-operations", config = true }, - -- Improved functionality when working with neovim config - { "folke/neodev.nvim", opts = {} }, - }, - config = function() - -- import lspconfig plugin - local lspconfig = require("lspconfig") - - -- import mason_lspconfig plugin - local mason_lspconfig = require("mason-lspconfig") - - -- import cmp-nvim-lsp plugin - local cmp_nvim_lsp = require("cmp_nvim_lsp") - - local keymap = vim.keymap -- for conciseness - - -- nvim_create_autocmd - used to execute some logic automaticaly on a specific event - -- Here it is used the LSP server attaches to file - vim.api.nvim_create_autocmd("LspAttach", { - -- Grouping together autocommands. Here we creating new group and calling it "UserLspConfig" - group = vim.api.nvim_create_augroup("UserLspConfig", {}), - -- callback defining logic to execute on the event - callback = function(ev) - -- Buffer local mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - local opts = { buffer = ev.buf, silent = true } - - -- set keybinds - opts.desc = "Show LSP references" - keymap.set("n", "gR", "Telescope lsp_references", opts) -- show definition, references - - opts.desc = "Go to declaration" - keymap.set("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration - - opts.desc = "Show LSP definitions" - keymap.set("n", "gd", "Telescope lsp_definitions", opts) -- show lsp definitions - - opts.desc = "Show LSP implementations" - keymap.set("n", "gi", "Telescope lsp_implementations", opts) -- show lsp implementations - - opts.desc = "Show LSP type definitions" - keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) -- show lsp type definitions - - opts.desc = "See available code actions" - keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection - - opts.desc = "Smart rename" - keymap.set("n", "rn", vim.lsp.buf.rename, opts) -- smart rename - - opts.desc = "Show buffer diagnostics" - keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) -- show diagnostics for file - - opts.desc = "Show line diagnostics" - keymap.set("n", "d", vim.diagnostic.open_float, opts) -- show diagnostics for line - - opts.desc = "Go to previous diagnostic" - keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer - - opts.desc = "Go to next diagnostic" - keymap.set("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer - - opts.desc = "Show documentation for what is under cursor" - keymap.set("n", "K", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor - - opts.desc = "Restart LSP" - keymap.set("n", "rs", ":LspRestart", opts) -- mapping to restart lsp if necessary - - opts.desc = "Run formatting on current buffer" - keymap.set("n", "f", function() - vim.lsp.buf.format({ async = true }) - end, opts) - end, - }) - - -- used to enable autocompletion (assign to every lsp server config) - local capabilities = cmp_nvim_lsp.default_capabilities() - - mason_lspconfig.setup_handlers({ - -- default handler for installed servers - function(server_name) - lspconfig[server_name].setup({ - capabilities = capabilities, - }) - end, - ["clangd"] = function() - lspconfig["clangd"].setup({ - filetypes = { "c" }, - cmd = { - "clangd", - "--offset-encoding=utf-16", - }, - }) - end, - ["lua_ls"] = function() - -- configure lua server (with special settings) - lspconfig["lua_ls"].setup({ - capabilities = capabilities, - settings = { - Lua = { - -- make the language server recognize "vim" global - diagnostics = { - globals = { "vim" }, - }, - completion = { - callSnippet = "Replace", - }, - }, - }, - }) - end, - }) - - -- Ruff setup - lspconfig.ruff.setup({ - init_options = { - settings = { - -- Ruff language server settings go here - logLevel = "debug", - }, - }, - }) - - -- Pyright setup - lspconfig.pyright.setup({ - settings = { - pyright = { - -- Using Ruff's import organizer - disableOrganizeImports = true, - }, - python = { - analysis = { - -- Ignore all files for analysis to exclusively use Ruff for linting - ignore = { "*" }, - diagnosticMode = "off", - typeCheckingMode = "off", - }, - }, - }, - }) - end, -} diff --git a/lua/t0xa/plugins/lsp/mason.lua b/lua/t0xa/plugins/lsp/mason.lua deleted file mode 100644 index 2804377..0000000 --- a/lua/t0xa/plugins/lsp/mason.lua +++ /dev/null @@ -1,49 +0,0 @@ -return { - "williamboman/mason.nvim", - dependencies = { - "williamboman/mason-lspconfig.nvim", -- util for better language servers manipulation - "WhoIsSethDaniel/mason-tool-installer.nvim", - }, - config = function() - -- import mason - local mason = require("mason") - - -- import mason-lspconfig - local mason_lspconfig = require("mason-lspconfig") - - local mason_tool_installer = require("mason-tool-installer") - - -- enable mason and configure icons - mason.setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗", - }, - }, - }) - - mason_lspconfig.setup({ - -- list of servers for mason to install - ensure_installed = { - "lua_ls", - "pyright", - "gopls", - }, - }) - - mason_tool_installer.setup({ - ensure_installed = { - "golines", - "goimports-reviser", - "prettier", -- prettier formatter - "stylua", -- lua formatter - "ruff", -- Python formatter and linter - "gofumpt", - -- Astra settings for 3.7 Python - -- NOTE: On Astra you need to install Ruff as standalone package - }, - }) - end, -} diff --git a/lua/t0xa/plugins/lualine.lua b/lua/t0xa/plugins/lualine.lua deleted file mode 100644 index 502d8d4..0000000 --- a/lua/t0xa/plugins/lualine.lua +++ /dev/null @@ -1,24 +0,0 @@ -return { - "nvim-lualine/lualine.nvim", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - local lualine = require("lualine") - -- configure lualine with modified theme - lualine.setup({ - options = { - -- theme = "tokyonight", - -- theme = "catppuccin-mocha", - theme = "gruvbox-material", - }, - sections = { - lualine_c = { - { - "filename", - file_status = true, - path = 2, - }, - }, - }, - }) - end, -} diff --git a/lua/t0xa/plugins/neogen.lua b/lua/t0xa/plugins/neogen.lua deleted file mode 100644 index e838b1e..0000000 --- a/lua/t0xa/plugins/neogen.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - "danymat/neogen", - version = "*", -- Follow only stable versions - enabled = true, - config = function() - local neogen = require("neogen") - neogen.setup({ - enabled = true - }) - local keymap = vim.keymap - local opts = { noremap = true, silent = true } - keymap.set("n", "ids", ":lua require('neogen').generate()", opts) - end, - -- config = true, -} diff --git a/lua/t0xa/plugins/none-ls.lua b/lua/t0xa/plugins/none-ls.lua deleted file mode 100644 index 0b57679..0000000 --- a/lua/t0xa/plugins/none-ls.lua +++ /dev/null @@ -1,18 +0,0 @@ -return { - "nvimtools/none-ls.nvim", - dependencies = { - "nvimtools/none-ls-extras.nvim", - }, - config = function() - local null_ls = require("null-ls") - - null_ls.setup({ - sources = { - null_ls.builtins.formatting.gofumpt, - null_ls.builtins.formatting.goimports_reviser, - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.golines, - }, - }) - end, -} diff --git a/lua/t0xa/plugins/nvim-cmp.lua b/lua/t0xa/plugins/nvim-cmp.lua deleted file mode 100644 index 557a061..0000000 --- a/lua/t0xa/plugins/nvim-cmp.lua +++ /dev/null @@ -1,90 +0,0 @@ -return { - "hrsh7th/nvim-cmp", - event = "InsertEnter", -- Only load plugin when in INSERT mode - dependencies = { - "hrsh7th/cmp-buffer", -- source for text in buffer - "hrsh7th/cmp-path", -- source for file system paths - { - "L3MON4D3/LuaSnip", - -- follow latest release. - version = "v2.*", -- Replace by the latest released major (first number of latest release) - }, - "saadparwaiz1/cmp_luasnip", -- for autocompletion - "rafamadriz/friendly-snippets", -- useful snippets - "onsails/lspkind.nvim", -- vs-code like pictograms - }, - config = function() - -- Load custom snippets from path - require("luasnip.loaders.from_vscode").lazy_load() - require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.fn.stdpath("config") .. "/snippets/" }) - - local cmp = require("cmp") - local luasnip = require("luasnip") - local lspkind = require("lspkind") - - -- loads vscode style snippets from installed plugins (e.g. friendly-snippets) - require("luasnip.loaders.from_vscode").lazy_load() - - cmp.setup({ - completion = { - completeopt = "menu,menuone,preview,noselect", - }, - snippet = { -- configure how nvim-cmp interacts with snippet engine - expand = function(args) - luasnip.lsp_expand(args.body) - end, - }, - mapping = cmp.mapping.preset.insert({ - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm({ select = true }), - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.locally_jumpable(1) then - luasnip.jump(1) - else - fallback() - end - end, { "i", "s" }), - - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - else - fallback() - end - end, { "i", "s" }), - }), - -- sources for autocompletion - -- !! Priority is important - autocompletion will be ordered from top to bottom - sources = cmp.config.sources({ - { name = "nvim_lsp" }, -- nvim LSP servers - { name = "luasnip" }, -- snippets - { name = "buffer" }, -- text within current buffer - { name = "path" }, -- file system paths - }), - - -- configure lspkind for vs-code like pictograms in completion menu - formatting = { - format = lspkind.cmp_format({ - maxwidth = 50, - ellipsis_char = "...", - }), - }, - }) - - cmp.setup.filetype({ "sql" }, { - sources = { - { name = "vim-dadbod-completion" }, - { name = "buffer" } - } - }) - end, -} diff --git a/lua/t0xa/plugins/nvim-tree.lua b/lua/t0xa/plugins/nvim-tree.lua deleted file mode 100644 index 2e4098a..0000000 --- a/lua/t0xa/plugins/nvim-tree.lua +++ /dev/null @@ -1,43 +0,0 @@ -return { - -} --- return { --- "nvim-tree/nvim-tree.lua", --- dependencies = "nvim-tree/nvim-web-devicons", --- config = function() --- local nvimtree = require("nvim-tree") --- -- recommended settings from nvim-tree documentation --- vim.g.loaded_netrw = 1 --- vim.g.loaded_netrwPlugin = 1 --- --- nvimtree.setup({ --- view = { --- -- width = 35, --- adaptive_size = true, --- relativenumber = true, --- }, --- -- disable window_picker for explorer to work well with window splits --- actions = { --- open_file = { --- window_picker = { --- enable = true, --- }, --- }, --- }, --- -- Custom list of vim regex for names that will not be shown --- filters = { --- custom = { ".DS_Store" }, --- }, --- -- Show files ignored by git --- git = { --- ignore = false, --- }, --- }) --- --- -- set nvim-tree keypmaps --- local keymap = vim.keymap --- keymap.set('n', 'nt', ':NvimTreeToggle', {desc = "Toggle file explorer"}) --- keymap.set('n', 'nf', ':NvimTreeFindFileToggle', {desc = "Toggle file explorer on current file"}) --- --- end --- } diff --git a/lua/t0xa/plugins/obsidian.lua b/lua/t0xa/plugins/obsidian.lua deleted file mode 100644 index 06603bf..0000000 --- a/lua/t0xa/plugins/obsidian.lua +++ /dev/null @@ -1,32 +0,0 @@ -return { - "epwalsh/obsidian.nvim", - version = "*", -- recommended, use latest release instead of latest commit - lazy = true, - ft = "markdown", - dependencies = { - -- Required. - "nvim-lua/plenary.nvim", - }, - opts = { - workspaces = { - { - name = "personal", - path = os.getenv("OBSIDIAN_NOTES_PATH"), - }, - }, - templates = { - folder = "Templates", - date_format = "%d.%m.%Y", - time_format = "%H:%M", - }, - -- disable adding properties on top of file on save - disable_frontmatter = true, - ui = { - enable = false - }, - follow_url_func = function(url) - print("Hello from URL") - vim.fn.jobstart({ "xdg-open", url }) - end, - }, -} diff --git a/lua/t0xa/plugins/plenary.lua b/lua/t0xa/plugins/plenary.lua deleted file mode 100644 index 9a1441c..0000000 --- a/lua/t0xa/plugins/plenary.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - "nvim-lua/plenary.nvim" -} diff --git a/lua/t0xa/plugins/rust-tools.lua b/lua/t0xa/plugins/rust-tools.lua deleted file mode 100644 index 2a55153..0000000 --- a/lua/t0xa/plugins/rust-tools.lua +++ /dev/null @@ -1,3 +0,0 @@ -return { - "simrat39/rust-tools.nvim", -} diff --git a/lua/t0xa/plugins/telescope.lua b/lua/t0xa/plugins/telescope.lua deleted file mode 100644 index 9949f7d..0000000 --- a/lua/t0xa/plugins/telescope.lua +++ /dev/null @@ -1,41 +0,0 @@ -return { - "nvim-telescope/telescope.nvim", - tag = "0.1.6", - dependencies = { - "nvim-lua/plenary.nvim", - -- Improving performance of finder - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - -- Display dev icons - "nvim-tree/nvim-web-devicons", - "folke/todo-comments.nvim", - }, - config = function() - local telescope = require("telescope") - local actions = require("telescope.actions") - - telescope.setup({ - defaults = { - path_display = { "smart" }, - mappings = { - i = { - [""] = actions.move_selection_previous, -- move to prev result - [""] = actions.move_selection_next, -- move to next result - }, - }, - }, - }) - - telescope.load_extension("fzf") -- load FZF extension to improve performance - - local builtin = require("telescope.builtin") - local keymap = vim.keymap - keymap.set("n", "ff", builtin.find_files, { desc = "FZF: find files in cwd" }) - keymap.set("n", "fml", builtin.marks, { desc = "FZF: find marks list" }) - keymap.set("n", "fmp", builtin.man_pages, { desc = "FZF: find available man pages" }) - keymap.set("n", "fg", builtin.live_grep, { desc = "FZF: find string in cwd" }) - keymap.set("n", "fb", builtin.buffers, { desc = "FZF: display opened buffers" }) - keymap.set("n", "fh", builtin.help_tags, { desc = "FZF: display help tags" }) - keymap.set("n", "ft", "TodoTelescope", { desc = "FZF: display TODO comments" }) - keymap.set("n", "fds", builtin.lsp_document_symbols, { desc = "FZF: Document symbols" }) - end, -} diff --git a/lua/t0xa/plugins/todo-comments.lua b/lua/t0xa/plugins/todo-comments.lua deleted file mode 100644 index f74baa9..0000000 --- a/lua/t0xa/plugins/todo-comments.lua +++ /dev/null @@ -1,21 +0,0 @@ -return { - "folke/todo-comments.nvim", - event = { "BufReadPre", "BufNewFile" }, - dependencies = { "nvim-lua/plenary.nvim" }, - config = function() - local todo_comments = require("todo-comments") - - -- set keymaps - local keymap = vim.keymap -- for conciseness - - keymap.set("n", "]t", function() - todo_comments.jump_next() - end, { desc = "Next todo comment" }) - - keymap.set("n", "[t", function() - todo_comments.jump_prev() - end, { desc = "Previous todo comment" }) - - todo_comments.setup() - end, -} diff --git a/lua/t0xa/plugins/treesitter.lua b/lua/t0xa/plugins/treesitter.lua deleted file mode 100644 index a5edee1..0000000 --- a/lua/t0xa/plugins/treesitter.lua +++ /dev/null @@ -1,66 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - -- open this plugin on two events: - -- BufReadPre - open existing file - -- BufNewFile - open new file - event = { "BufReadPre", "BufNewFile" }, - build = ":TSUpdate", -- Run whenever this plugin is installed or updated - dependencies = { - "windwp/nvim-ts-autotag", -- Auto-closing functionality within treesitter - }, - config = function() - -- import nvim-treesitter plugin - local treesitter = require("nvim-treesitter.configs") - - -- Configure treesitter - -- treesitter.setup({ - -- -- enable syntax highlighting - -- highligh = { - -- enable = true, - -- }, - -- - -- -- enable better indentation - -- indent = { - -- enable = true, - -- }, - -- - -- -- enable auto-tagging - -- autotag = { - -- enable = true, - -- }, - -- - -- -- ensure these languages parsers are installed - -- ensure_installed = { - -- "python", - -- "go", - -- "lua", - -- "bash", - -- "json", - -- "javascript", - -- "jq", - -- "markdown", - -- "markdown_inline", - -- "regex", - -- "vim", - -- "dockerfile", - -- }, - -- }) - -- end, - treesitter.setup({ - ensure_installed = { - "python", - "lua", - "vim", - "vimdoc", - "query", - "elixir", - "heex", - "javascript", - "html", - }, - sync_install = false, - highlight = { enable = true }, - indent = { enable = true }, - }) - end, -} diff --git a/lua/t0xa/plugins/trouble.lua b/lua/t0xa/plugins/trouble.lua deleted file mode 100644 index 3741f30..0000000 --- a/lua/t0xa/plugins/trouble.lua +++ /dev/null @@ -1,37 +0,0 @@ -return { - "folke/trouble.nvim", - opts = {}, -- for default options, refer to the configuration section for custom setup. - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - { - "xX", - "Trouble diagnostics toggle filter.buf=0", - desc = "Buffer Diagnostics (Trouble)", - }, - { - "cs", - "Trouble symbols toggle focus=false", - desc = "Symbols (Trouble)", - }, - { - "cl", - "Trouble lsp toggle focus=false win.position=right", - desc = "LSP Definitions / references / ... (Trouble)", - }, - { - "xL", - "Trouble loclist toggle", - desc = "Location List (Trouble)", - }, - { - "xQ", - "Trouble qflist toggle", - desc = "Quickfix List (Trouble)", - }, - }, -} diff --git a/lua/t0xa/plugins/vim-tmux-navigator.lua b/lua/t0xa/plugins/vim-tmux-navigator.lua deleted file mode 100644 index 4421fed..0000000 --- a/lua/t0xa/plugins/vim-tmux-navigator.lua +++ /dev/null @@ -1,17 +0,0 @@ -return { - "christoomey/vim-tmux-navigator", - cmd = { - "TmuxNavigateLeft", - "TmuxNavigateDown", - "TmuxNavigateUp", - "TmuxNavigateRight", - "TmuxNavigatePrevious", - }, - keys = { - { "", "TmuxNavigateLeft" }, - { "", "TmuxNavigateDown" }, - { "", "TmuxNavigateUp" }, - { "", "TmuxNavigateRight" }, - { "", "TmuxNavigatePrevious" }, - }, -} diff --git a/lua/t0xa/plugins/which-key.lua b/lua/t0xa/plugins/which-key.lua deleted file mode 100644 index 078eebc..0000000 --- a/lua/t0xa/plugins/which-key.lua +++ /dev/null @@ -1,19 +0,0 @@ -return { - "folke/which-key.nvim", - -- Telling nvim that it can load this plugin later, and that it is not - -- that important for initial UI - event = "VeryLazy", - -- Function that will run while neovim startup instead of when plugin is actualy loads - init = function() - -- How long which-key will wait until activation - vim.o.timeout = true - vim.o.timeoutlen = 500 - end, - -- Options that will pass to setup function, but we are leaving it empty to use - -- default configuration - opts = { - -- your configuration comes here - -- or leave it empty to use the default settings - -- refer to the configuration section below - } -} diff --git a/snippets/go.json b/snippets/go.json deleted file mode 100644 index 28ce065..0000000 --- a/snippets/go.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "for statement": { - "prefix": "for", - "body": "for ${1:i} := 0; $1 < ${2:count}; $1${3:++} {\n\t$0\n}", - "description": "Snippet for a for loop" - }, - "for range statement": { - "prefix": "forrrrrr", - "body": "for ${1:_, }${2:var} := range ${3:var} {\n\t$0\n}", - "description": "Snippet for a for range loop" - }, - "if err != nil": { - "prefix": "iferr", - "body": "if err != nil {\n\t${1:return ${2:nil, }${3:err}}\n}", - "description": "Snippet for if err != nil" - } -} diff --git a/snippets/package.json b/snippets/package.json deleted file mode 100644 index 2d1f6e9..0000000 --- a/snippets/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "custom-snippets", - "engines": { - "vscode": "^1.11.0" - }, - "contributes": { - "snippets": [ - { - "language": "python", - "path": "./python.json" - }, - { - "language": "go", - "path": "./go.json" - } - - ] - } -} - diff --git a/snippets/python.json b/snippets/python.json deleted file mode 100644 index 34c6da5..0000000 --- a/snippets/python.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "implog": { - "prefix": "implog", - "body": [ - "import logging", - "_log = logging.getLogger(__name__)" - ], - "description": "Snippet for importing logger" - }, - "Log event": { - "prefix": "logevent", - "body": [ - "_log.error('${1:delimiter}' * 60)", - "_log.error(${2})", - "_log.error('${1:delimiter}' * 60)" - ], - "description": "Snippet for inserting error log" - }, - "Log debug": { - "prefix": "logdebug", - "body": [ - "_log.debug(${1:deug_body})" - ], - "description": "Snippet for inserting debug log" - }, - "tryexcept": { - "prefix": "tryexe", - "body": [ - "try:", - " print(x)", - "except ${1:exception}:", - " print('An exception occurred')" - ], - "description": "tryexcept method" - } -} -- 2.30.2 From 13e3813c29f1c8831a2b74d4b9dc795d08a5c386 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 20:41:19 +0300 Subject: [PATCH 02/41] Update README --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 6fb4778..6c1a72c 100644 --- a/README.md +++ b/README.md @@ -1 +1,11 @@ # Config refactor (v2.0) +## Useful links +- [Переписывание конфига с автором telescope](https://www.youtube.com/watch?v=kJVqxFnhIuw&t=510s) +- [Документация по Lua в Nvim](https://neovim.io/doc/user/lua-guide.html) +- [Конфиг TJ](https://github.com/tjdevries/config.nvim/tree/master) +## Разница между ftplugin и after/ftplugin +Суть одна и та-же: загрузка конфигураций для конкретных типов файлов, однако: +### ftplugin +Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут +### after/ftplugin +Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах -- 2.30.2 From 4700af86a06722196ab7f2001f4a094a23e1667c Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 20:47:04 +0300 Subject: [PATCH 03/41] Update README --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index 6c1a72c..9e9d0dd 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,34 @@ - [Переписывание конфига с автором telescope](https://www.youtube.com/watch?v=kJVqxFnhIuw&t=510s) - [Документация по Lua в Nvim](https://neovim.io/doc/user/lua-guide.html) - [Конфиг TJ](https://github.com/tjdevries/config.nvim/tree/master) +## Основные прицнипы формирования конфига +### Plugins +Разберем на примере `oil.nvim`: Сначала базовые настройки, такие как инструкция откуда качать и всякие зависимости и атрибуты по типу приоритета кладутся в директорию `custom/plugins` в виде названия плагина: +*lua/custom/plugins/oil.lua* +```lua +return { + "stevearc/oil.nvim", + dependencies = { { "echasnovski/mini.icons", opts = {} } }, + config = function() + require "custom/oil" + end, +} +``` +Затем, как можно видеть, сама функция настроек расположена отдельно в файле с идентичным названием, но в директории "повыше": +*lua/custom/oil.lua* +```lua +require("oil").setup{ + opts = { + keymaps = { + ["g?"] = "actions.show_help", + ... +} +``` +#### FAQ +> Зачем так мучаться? Не проще все кидать в один файл? + +Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`'ить файл настроек, не трогая конфигурации скачивания файлов, чтобы лишний раз не триггерить Lazy. + ## Разница между ftplugin и after/ftplugin Суть одна и та-же: загрузка конфигураций для конкретных типов файлов, однако: ### ftplugin -- 2.30.2 From 6ab96328ec8f1afa6a0bc7c6a61297c1cb6710be Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 20:57:39 +0300 Subject: [PATCH 04/41] Add keymaps and update README --- README.md | 2 ++ plugin/keymaps.lua | 7 +++++++ 2 files changed, 9 insertions(+) create mode 100644 plugin/keymaps.lua diff --git a/README.md b/README.md index 9e9d0dd..95edd31 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,8 @@ - [Документация по Lua в Nvim](https://neovim.io/doc/user/lua-guide.html) - [Конфиг TJ](https://github.com/tjdevries/config.nvim/tree/master) ## Основные прицнипы формирования конфига +### Root plugin папка +Скрипты в этой папке загружаются автоматически после инициализации `neovim`, но до загрузки файлов типа `ftplugin/` или `after/`. ### Plugins Разберем на примере `oil.nvim`: Сначала базовые настройки, такие как инструкция откуда качать и всякие зависимости и атрибуты по типу приоритета кладутся в директорию `custom/plugins` в виде названия плагина: *lua/custom/plugins/oil.lua* diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua new file mode 100644 index 0000000..b6ad43a --- /dev/null +++ b/plugin/keymaps.lua @@ -0,0 +1,7 @@ +local set = vim.keymap.set + +-- Basic movement keybinds, these make navigating splits easy for me +set("n", "", "") +set("n", "", "") +set("n", "", "") +set("n", "", "") -- 2.30.2 From 6c1e628a407017510b8455451c48a5e6bbf519a2 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 22:15:52 +0300 Subject: [PATCH 05/41] Add basic options --- plugin/options.lua | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 plugin/options.lua diff --git a/plugin/options.lua b/plugin/options.lua new file mode 100644 index 0000000..36a9696 --- /dev/null +++ b/plugin/options.lua @@ -0,0 +1,26 @@ +local opt = vim.opt + +-- Command to show inline what are you trying to perform +opt.inccommand = "split" + +-- Search settings to toggle "smart case" search only if 1+ uppercase char +-- persist in search line +opt.smartcase = true +opt.ignorecase = true + +-- Enable line numbers and relative setting +opt.number = true +opt.relativenumber = true + +-- Tabulation and indentation settings +opt.shiftwidth = 2 -- Set spaces for tabs == 2 +opt.tabstop = 2 -- Set spaces for indent with == 2 +opt.expandtab = true -- use number of spaces to insert a +opt.softtabstop = 2 + +-- Disable swap files creation +opt.swapfile = false + +-- Add line at 80 symbols +opt.colorcolumn = "80" + -- 2.30.2 From 77b3d15322f4d9bb48d8eae976cd5ac214a4d161 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 22:22:17 +0300 Subject: [PATCH 06/41] Add colorschemes --- lua/custom/colorschemes.lua | 9 +++++++++ lua/custom/plugins/colorschemes.lua | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 lua/custom/colorschemes.lua create mode 100644 lua/custom/plugins/colorschemes.lua diff --git a/lua/custom/colorschemes.lua b/lua/custom/colorschemes.lua new file mode 100644 index 0000000..5a92f02 --- /dev/null +++ b/lua/custom/colorschemes.lua @@ -0,0 +1,9 @@ +-- Turn on termguicolors for colorschemes +-- (Have to use true color terminal to see theese setting work) +vim.opt.termguicolors = true +vim.opt.background = "dark" -- colorschemes that can be light or dark will be made dark +vim.opt.signcolumn = "yes" -- show sigh columns so that text doesn't shift + +vim.g.gruvbox_material_background = 'hard' +vim.g.gruvbox_material_enable_italic = true +vim.cmd.colorscheme("gruvbox-material") diff --git a/lua/custom/plugins/colorschemes.lua b/lua/custom/plugins/colorschemes.lua new file mode 100644 index 0000000..3af066c --- /dev/null +++ b/lua/custom/plugins/colorschemes.lua @@ -0,0 +1,19 @@ +return { + "folke/tokyonight.nvim", + dependencies = { + "ellisonleao/gruvbox.nvim", + -- "morphez/gruvbox.nvim", + "sainnhe/everforest", + "sainnhe/gruvbox-material", + "rebelot/kanagawa.nvim", + "catppuccin/nvim", + "folke/tokyonight.nvim", + "luisiacc/gruvbox-baby", + }, + lazy = false, + priority = 1000, + config = function() + require "custom/colorschemes" + end, +} + -- 2.30.2 From 034fe4f764533e4c18a924b859d5477074d73c75 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 22:25:30 +0300 Subject: [PATCH 07/41] Add todo comment for coloscheme settings --- lua/custom/plugins/colorschemes.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lua/custom/plugins/colorschemes.lua b/lua/custom/plugins/colorschemes.lua index 3af066c..7fe659b 100644 --- a/lua/custom/plugins/colorschemes.lua +++ b/lua/custom/plugins/colorschemes.lua @@ -1,8 +1,9 @@ +-- TODO: Need to refactor ways of downloading colorschemes +-- Now it is just a hack to download all colorschemes as dependecies return { "folke/tokyonight.nvim", dependencies = { "ellisonleao/gruvbox.nvim", - -- "morphez/gruvbox.nvim", "sainnhe/everforest", "sainnhe/gruvbox-material", "rebelot/kanagawa.nvim", -- 2.30.2 From a45f1d47ecb93a311a144f9101c091272bcbf804 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 22:33:00 +0300 Subject: [PATCH 08/41] Remap leader key for , --- init.lua | 9 +++++---- main.py | 1 + plugin/keymaps.lua | 4 ++++ plugin/options.lua | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 main.py diff --git a/init.lua b/init.lua index a7a4306..8b6bc7e 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,8 @@ +-- Making leader () key to space +vim.g.mapleader = "," +-- Making local leader () key to backslash +vim.g.maplocalleader = "\\" + -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then @@ -15,10 +20,6 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then end vim.opt.rtp:prepend(lazypath) --- Making leader () key to space -vim.g.mapleader = " " --- Making local leader () key to backslash -vim.g.maplocalleader = "\\" -- Setup lazy.nvim require("lazy").setup({ diff --git a/main.py b/main.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/main.py @@ -0,0 +1 @@ + diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua index b6ad43a..5af4f86 100644 --- a/plugin/keymaps.lua +++ b/plugin/keymaps.lua @@ -5,3 +5,7 @@ set("n", "", "") set("n", "", "") set("n", "", "") set("n", "", "") + +-- Bindings for reloading LUA files (used when working with lua files) +set("n", "x", ".lua", { desc = "Execute the current lne" }) +set("n", "x", "source %", { desc = "Execute the current file" }) diff --git a/plugin/options.lua b/plugin/options.lua index 36a9696..01e1430 100644 --- a/plugin/options.lua +++ b/plugin/options.lua @@ -1,7 +1,7 @@ local opt = vim.opt -- Command to show inline what are you trying to perform -opt.inccommand = "split" +inccommand = "split" -- Search settings to toggle "smart case" search only if 1+ uppercase char -- persist in search line -- 2.30.2 From 66fa89277ea6564d01bca98a69771b5b39193101 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 22:47:03 +0300 Subject: [PATCH 09/41] Add telescope basic config --- lua/custom/plugins/telescope.lua | 12 ++++++++++++ lua/custom/telescope.lua | 19 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 lua/custom/plugins/telescope.lua create mode 100644 lua/custom/telescope.lua diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 0000000..d2c6291 --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,12 @@ +return { + "nvim-telescope/telescope.nvim", + dependencies = { + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "folke/todo-comments.nvim", + }, + config = function() + require "custom.telescope" + end, +} diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua new file mode 100644 index 0000000..0ea13f1 --- /dev/null +++ b/lua/custom/telescope.lua @@ -0,0 +1,19 @@ +require("telescope").setup { + defaults = { + path_display = { "smart" }, + }, +} + +-- Load fzf extension to imporve performance +pcall(require("telescope").load_extension, "fzf") + +local builtin = require("telescope.builtin") +local keymap = vim.keymap +keymap.set("n", "ff", builtin.find_files, { desc = "FZF: find files in cwd" }) +keymap.set("n", "fml", builtin.marks, { desc = "FZF: find marks list" }) +keymap.set("n", "fmp", builtin.man_pages, { desc = "FZF: find available man pages" }) +keymap.set("n", "fg", builtin.live_grep, { desc = "FZF: find string in cwd" }) +keymap.set("n", "fb", builtin.buffers, { desc = "FZF: display opened buffers" }) +keymap.set("n", "fh", builtin.help_tags, { desc = "FZF: display help tags" }) +keymap.set("n", "ft", "TodoTelescope", { desc = "FZF: display TODO comments" }) +keymap.set("n", "fds", builtin.lsp_document_symbols, { desc = "FZF: Document symbols" }) -- 2.30.2 From db10325c977249dfd096c9169fa06e479fee1943 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 22:58:20 +0300 Subject: [PATCH 10/41] Add treesitter plugin --- lua/custom/plugins/treesitter.lua | 14 ++++++++++++++ lua/custom/treesitter.lua | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 lua/custom/plugins/treesitter.lua create mode 100644 lua/custom/treesitter.lua diff --git a/lua/custom/plugins/treesitter.lua b/lua/custom/plugins/treesitter.lua new file mode 100644 index 0000000..2b2979a --- /dev/null +++ b/lua/custom/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + "nvim-treesitter/nvim-treesitter", + -- open this plugin on two events: + -- BufReadPre - open existing file + -- BufNewFile - open new file + event = { "BufReadPre", "BufNewFile" }, + build = ":TSUpdate", -- Run whenever this plugin is installed or updated + dependencies = { + "windwp/nvim-ts-autotag", -- Auto-closing functionality within treesitter + }, + config = function() + require "custom/treesitter" + end, +} diff --git a/lua/custom/treesitter.lua b/lua/custom/treesitter.lua new file mode 100644 index 0000000..1d65998 --- /dev/null +++ b/lua/custom/treesitter.lua @@ -0,0 +1,17 @@ +require'nvim-treesitter.configs'.setup { + ensure_installed = { + "python", + "lua", + "vim", + "vimdoc", + "query", + "elixir", + "heex", + "javascript", + "html", + "go" + }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, +} -- 2.30.2 From ee4f78902be397e1d4d84bf317f275220da16039 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 23:12:43 +0300 Subject: [PATCH 11/41] Add nvim-cmp basic config --- lua/custom/completion.lua | 43 +++++++++++++++++++++++++++++++ lua/custom/plugins/completion.lua | 19 ++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 lua/custom/completion.lua create mode 100644 lua/custom/plugins/completion.lua diff --git a/lua/custom/completion.lua b/lua/custom/completion.lua new file mode 100644 index 0000000..72cb31e --- /dev/null +++ b/lua/custom/completion.lua @@ -0,0 +1,43 @@ +-- Set some settings for competion +-- For more info type `:help completeopt` +-- menu: Show menu when completions available (more than 1) +-- menuone: Show menu even when there is only 1 option +-- noselect: Force user to select convinient option +vim.opt.completeopt = { "menu", "menuone", "noselect" } + +local lspkind = require "lspkind" + +local kind_formatter = lspkind.cmp_format { + mode = "symbol_text", + menu = { + buffer = "[buf]", + nvim_lsp = "[LSP]", + nvim_lua = "[api]", + path = "[path]", + luasnip = "[snip]", + gh_issues = "[issues]", + tn = "[TabNine]", + eruby = "[erb]", + }, +} + +local cmp = require "cmp" + +cmp.setup { + sources = { + { name = "nvim_lsp" }, + { name = "path" }, + { name = "buffer" }, + }, + mapping = { + [""] = cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Insert }, + [""] = cmp.mapping( + cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }, + { "i", "c" } + ), + }, +} diff --git a/lua/custom/plugins/completion.lua b/lua/custom/plugins/completion.lua new file mode 100644 index 0000000..482e700 --- /dev/null +++ b/lua/custom/plugins/completion.lua @@ -0,0 +1,19 @@ +return { + "hrsh7th/nvim-cmp", + event = "InsertEnter", -- Only load plugin when in INSERT mode + dependencies = { + "hrsh7th/cmp-buffer", -- source for text in buffer + "hrsh7th/cmp-path", -- source for file system paths + { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + }, + "saadparwaiz1/cmp_luasnip", -- for autocompletion + "rafamadriz/friendly-snippets", -- useful snippets + "onsails/lspkind.nvim", -- vs-code like pictograms + }, + config = function() + require "custom/completion" + end, +} -- 2.30.2 From f9c4d63afb7f47813e064efb03a8cd49d0474d52 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Fri, 31 Jan 2025 23:45:06 +0300 Subject: [PATCH 12/41] Add completion basic settings --- lua/custom/lsp.lua | 193 ++++++++++++++++++++++++++++++ lua/custom/plugins/completion.lua | 1 + lua/custom/plugins/lsp.lua | 35 ++++++ 3 files changed, 229 insertions(+) create mode 100644 lua/custom/lsp.lua create mode 100644 lua/custom/plugins/lsp.lua diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua new file mode 100644 index 0000000..752259b --- /dev/null +++ b/lua/custom/lsp.lua @@ -0,0 +1,193 @@ +local lspconfig = require("lspconfig") +local mason_lspconfig = require("mason-lspconfig") +local cmp_nvim_lsp = require("cmp_nvim_lsp") + +local keymap = vim.keymap + +local capabilities = nil +if pcall(require, "cmp_nvim_lsp") then + capabilities = require("cmp_nvim_lsp").default_capabilities() +end + + +local servers = { + gopls = { + settings = { + gopls = { + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + }, + }, + }, + ruff = { + init_options = { + settings = { + -- Ruff language server settings go here + logLevel = "debug", + }, + }, + }, + pyright = { + settings = { + pyright = { + -- Using Ruff's import organizer + disableOrganizeImports = true, + }, + python = { + analysis = { + -- Ignore all files for analysis to exclusively use Ruff for linting + ignore = { "*" }, + diagnosticMode = "off", + typeCheckingMode = "off", + }, + }, + }, + }, + lua_ls = { + capabilities = capabilities, + settings = { + Lua = { + -- make the language server recognize "vim" global + diagnostics = { + globals = { "vim" }, + }, + completion = { + callSnippet = "Replace", + }, + }, + }, + }, + clangd = { + filetypes = { "c" }, + cmd = { + "clangd", + "--offset-encoding=utf-16", + }, + }, +} + +local servers_to_install = vim.tbl_filter(function(key) + local t = servers[key] + if type(t) == "table" then + return not t.manual_install + else + return t + end +end, vim.tbl_keys(servers)) + + + +require("mason").setup() +local ensure_installed = { + "stylua", + "lua_ls", + "ruff", + "gopls", + "gofumpt", + "golines", + "prettier", + "pyright" +} + +vim.list_extend(ensure_installed, servers_to_install) +require("mason-tool-installer").setup { ensure_installed = ensure_installed } + +for name, config in pairs(servers) do + if config == true then + config = {} + end + config = vim.tbl_deep_extend("force", {}, { + capabilities = capabilities, + }, config) + + lspconfig[name].setup(config) +end + +for name, config in pairs(servers) do + if config == true then + config = {} + end + config = vim.tbl_deep_extend("force", {}, { + capabilities = capabilities, + }, config) + + lspconfig[name].setup(config) +end + +-- Here it is used the LSP server attaches to file +vim.api.nvim_create_autocmd("LspAttach", { + -- Grouping together autocommands. + -- Here we creating new group and calling it "UserLspConfig" + group = vim.api.nvim_create_augroup("UserLspConfig", {}), + -- callback defining logic to execute on the event + callback = function(ev) + -- Buffer local mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions + local opts = { buffer = ev.buf, silent = true } + + -- set keybinds + -- show definition, references + opts.desc = "Show LSP references" + keymap.set("n", "gR", "Telescope lsp_references", opts) + + -- go to declaration + opts.desc = "Go to declaration" + keymap.set("n", "gD", vim.lsp.buf.declaration, opts) + + -- show lsp definitions + opts.desc = "Show LSP definitions" + keymap.set("n", "gd", "Telescope lsp_definitions", opts) + + -- show lsp implementations + opts.desc = "Show LSP implementations" + keymap.set("n", "gi", "Telescope lsp_implementations", opts) + + -- show lsp type definitions + opts.desc = "Show LSP type definitions" + keymap.set("n", "gt", "Telescope lsp_type_definitions", opts) + + -- see available code actions, in visual mode will apply to selection + opts.desc = "See available code actions" + keymap.set({ "n", "v" }, "ca", vim.lsp.buf.code_action, opts) + + -- smart rename + opts.desc = "Smart rename" + keymap.set("n", "rn", vim.lsp.buf.rename, opts) + + -- show diagnostics for file + opts.desc = "Show buffer diagnostics" + keymap.set("n", "D", "Telescope diagnostics bufnr=0", opts) + + -- show diagnostics for line + opts.desc = "Show line diagnostics" + keymap.set("n", "d", vim.diagnostic.open_float, opts) + + -- jump to previous diagnostic in buffer + opts.desc = "Go to previous diagnostic" + keymap.set("n", "[d", vim.diagnostic.goto_prev, opts) + + -- jump to next diagnostic in buffer + opts.desc = "Go to next diagnostic" + keymap.set("n", "]d", vim.diagnostic.goto_next, opts) + + -- show documentation for what is under cursor + opts.desc = "Show documentation for what is under cursor" + keymap.set("n", "K", vim.lsp.buf.hover, opts) + + -- mapping to restart lsp if necessary + opts.desc = "Restart LSP" + keymap.set("n", "rs", ":LspRestart", opts) + + opts.desc = "Run formatting on current buffer" + keymap.set("n", "f", function() + vim.lsp.buf.format({ async = true }) + end, opts) + end, +}) diff --git a/lua/custom/plugins/completion.lua b/lua/custom/plugins/completion.lua index 482e700..2628a4c 100644 --- a/lua/custom/plugins/completion.lua +++ b/lua/custom/plugins/completion.lua @@ -12,6 +12,7 @@ return { "saadparwaiz1/cmp_luasnip", -- for autocompletion "rafamadriz/friendly-snippets", -- useful snippets "onsails/lspkind.nvim", -- vs-code like pictograms + "hrsh7th/cmp-nvim-lsp", }, config = function() require "custom/completion" diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua new file mode 100644 index 0000000..022c2eb --- /dev/null +++ b/lua/custom/plugins/lsp.lua @@ -0,0 +1,35 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + { + --`lazydev` configures Lua LSP for your Neovim config, runtime and plugins + -- used for completion, annotations and signatures of Neovim apis + "folke/lazydev.nvim", + ft = "lua", + opts = { + library = { + -- Load luvit types when the `vim.uv` word is found + { path = "luvit-meta/library", words = { "vim%.uv" } }, + }, + }, + }, + { "Bilal2453/luvit-meta", lazy = true }, + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "WhoIsSethDaniel/mason-tool-installer.nvim", + + -- Some enhancements for notifications in bottom-right corner + { "j-hui/fidget.nvim", opts = {} }, + + -- Following plugin enables enhancements for diagnostics info + -- { "https://git.sr.ht/~whynothugo/lsp_lines.nvim" }, + + -- Autoformatting + "stevearc/conform.nvim", + }, + config = function() + require "custom/lsp" + end, + }, +} -- 2.30.2 From d315070a8be03f87b0cdfd1b912c2bfbba7c9792 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 07:55:33 +0300 Subject: [PATCH 13/41] Fix incommand option --- plugin/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/options.lua b/plugin/options.lua index 01e1430..36a9696 100644 --- a/plugin/options.lua +++ b/plugin/options.lua @@ -1,7 +1,7 @@ local opt = vim.opt -- Command to show inline what are you trying to perform -inccommand = "split" +opt.inccommand = "split" -- Search settings to toggle "smart case" search only if 1+ uppercase char -- persist in search line -- 2.30.2 From e63ff2e483661e2d0fdde6b37e88af539d7dd293 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 08:15:17 +0300 Subject: [PATCH 14/41] Fix some checkhealth issues --- lua/custom/lsp.lua | 4 +--- lua/custom/treesitter.lua | 2 +- plugin/providers.lua | 3 +++ 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 plugin/providers.lua diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua index 752259b..f0eb875 100644 --- a/lua/custom/lsp.lua +++ b/lua/custom/lsp.lua @@ -1,6 +1,4 @@ local lspconfig = require("lspconfig") -local mason_lspconfig = require("mason-lspconfig") -local cmp_nvim_lsp = require("cmp_nvim_lsp") local keymap = vim.keymap @@ -123,7 +121,7 @@ end -- Here it is used the LSP server attaches to file vim.api.nvim_create_autocmd("LspAttach", { - -- Grouping together autocommands. + -- Grouping together autocommands. -- Here we creating new group and calling it "UserLspConfig" group = vim.api.nvim_create_augroup("UserLspConfig", {}), -- callback defining logic to execute on the event diff --git a/lua/custom/treesitter.lua b/lua/custom/treesitter.lua index 1d65998..388efc8 100644 --- a/lua/custom/treesitter.lua +++ b/lua/custom/treesitter.lua @@ -1,4 +1,4 @@ -require'nvim-treesitter.configs'.setup { +require 'nvim-treesitter.configs'.setup { ensure_installed = { "python", "lua", diff --git a/plugin/providers.lua b/plugin/providers.lua new file mode 100644 index 0000000..1e00d4a --- /dev/null +++ b/plugin/providers.lua @@ -0,0 +1,3 @@ +-- Disable unneccesary providers +vim.g.loaded_ruby_provider = 0 +vim.g.loaded_perl_provider = 0 -- 2.30.2 From 80481e2f1d398391402f37e248b4684c806a51f0 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 08:22:39 +0300 Subject: [PATCH 15/41] Update README --- README.md | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 95edd31..e848958 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,33 @@ require("oil").setup{ opts = { keymaps = { ["g?"] = "actions.show_help", - ... + }, + }, } -``` +``` + #### FAQ > Зачем так мучаться? Не проще все кидать в один файл? -Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`'ить файл настроек, не трогая конфигурации скачивания файлов, чтобы лишний раз не триггерить Lazy. +Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`ить файл настроек, не трогая конфигурации скачивания файлов, чтобы лишний раз не триггерить Lazy. + +> Что делать, если в `checkhealth` выдается ошибка `luarocks not found`? + +Необходимо его установить по инструкции с [сайта](https://luarocks.org/) + +> Что делать, если при установке `luarocks` выдает ошибку что не найдены `.h` файлы? + +Надо установить хэдеры lua командой: +```bash +sudo apt install liblua5.3-dev +``` + +> checkhealth не может найти tree-sitter cli + +Надо установить соответствующий `npm` пакет: +```js +npm install -g tree-sitter-cli +``` ## Разница между ftplugin и after/ftplugin Суть одна и та-же: загрузка конфигураций для конкретных типов файлов, однако: @@ -39,3 +59,4 @@ require("oil").setup{ Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут ### after/ftplugin Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах + -- 2.30.2 From 9cc1cc99cb29178ccbebb7111443015d367ec41d Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 08:24:08 +0300 Subject: [PATCH 16/41] Update README --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e848958..a63a611 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,14 @@ require("oil").setup{ } ``` -#### FAQ +## Разница между ftplugin и after/ftplugin +Суть одна и та-же: загрузка конфигураций для конкретных типов файлов, однако: +### ftplugin +Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут +### after/ftplugin +Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах + +# FAQ > Зачем так мучаться? Не проще все кидать в один файл? Проще, но такое распараллеливание позволяет легче дебажить файлы настроек. Т.е. исправляя настройки мы можем просто `source`ить файл настроек, не трогая конфигурации скачивания файлов, чтобы лишний раз не триггерить Lazy. @@ -52,11 +59,3 @@ sudo apt install liblua5.3-dev ```js npm install -g tree-sitter-cli ``` - -## Разница между ftplugin и after/ftplugin -Суть одна и та-же: загрузка конфигураций для конкретных типов файлов, однако: -### ftplugin -Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут -### after/ftplugin -Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах - -- 2.30.2 From 8b4cda383453c95a8cd8b455f568496b149b428b Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 10:59:59 +0300 Subject: [PATCH 17/41] Add TODO-comments plugin --- lua/custom/plugins/todo.lua | 8 ++++++++ lua/custom/todo.lua | 12 ++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 lua/custom/plugins/todo.lua create mode 100644 lua/custom/todo.lua diff --git a/lua/custom/plugins/todo.lua b/lua/custom/plugins/todo.lua new file mode 100644 index 0000000..76b7eee --- /dev/null +++ b/lua/custom/plugins/todo.lua @@ -0,0 +1,8 @@ +return { + "folke/todo-comments.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { "nvim-lua/plenary.nvim" }, + config = function() + require "custom/todo" + end, +} diff --git a/lua/custom/todo.lua b/lua/custom/todo.lua new file mode 100644 index 0000000..e10a301 --- /dev/null +++ b/lua/custom/todo.lua @@ -0,0 +1,12 @@ +local todo_comments = require("todo-comments") +local keymap = vim.keymap + +keymap.set("n", "]t", function() + todo_comments.jump_next() +end, { desc = "Next todo comment" }) + +keymap.set("n", "[t", function() + todo_comments.jump_prev() +end, { desc = "Previous todo comment" }) + +todo_comments.setup(opts) -- 2.30.2 From 053816706e2acafc05dd9c9674a103c09747e314 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 11:05:39 +0300 Subject: [PATCH 18/41] Add negoen plugin --- lua/custom/neogen.lua | 7 +++++++ lua/custom/plugins/neogen.lua | 12 ++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 lua/custom/neogen.lua create mode 100644 lua/custom/plugins/neogen.lua diff --git a/lua/custom/neogen.lua b/lua/custom/neogen.lua new file mode 100644 index 0000000..c071acf --- /dev/null +++ b/lua/custom/neogen.lua @@ -0,0 +1,7 @@ +require("neogen").setup { + enabled = true +} + +local keymap = vim.keymap +local opts = { noremap = true, silent = true } +keymap.set("n", "ids", ":lua require('neogen').generate()", opts) diff --git a/lua/custom/plugins/neogen.lua b/lua/custom/plugins/neogen.lua new file mode 100644 index 0000000..1f0174e --- /dev/null +++ b/lua/custom/plugins/neogen.lua @@ -0,0 +1,12 @@ +-- Plugin for generating annotations +return { + { + "danymat/neogen", + config = true, + -- Uncomment next line if you want to follow only stable versions + version = "*", + config = function() + require "custom/neogen" + end, + } +} -- 2.30.2 From ecec0c4c56fa0764b39f9fd87524febb7c92dbb2 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 11:10:49 +0300 Subject: [PATCH 19/41] Add dressing and lualine plugins --- lua/custom/lualine.lua | 14 ++++++++++++++ lua/custom/plugins/dressing.lua | 4 ++++ lua/custom/plugins/lualine.lua | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 lua/custom/lualine.lua create mode 100644 lua/custom/plugins/dressing.lua create mode 100644 lua/custom/plugins/lualine.lua diff --git a/lua/custom/lualine.lua b/lua/custom/lualine.lua new file mode 100644 index 0000000..c968ac7 --- /dev/null +++ b/lua/custom/lualine.lua @@ -0,0 +1,14 @@ +require("lualine").setup({ + options = { + theme = "gruvbox-material", + }, + sections = { + lualine_c = { + { + "filename", + file_status = true, + path = 2, + }, + }, + }, +}) diff --git a/lua/custom/plugins/dressing.lua b/lua/custom/plugins/dressing.lua new file mode 100644 index 0000000..feadb27 --- /dev/null +++ b/lua/custom/plugins/dressing.lua @@ -0,0 +1,4 @@ +return { + "stevearc/dressing.nvim", + event = "VeryLazy" +} diff --git a/lua/custom/plugins/lualine.lua b/lua/custom/plugins/lualine.lua new file mode 100644 index 0000000..e17801b --- /dev/null +++ b/lua/custom/plugins/lualine.lua @@ -0,0 +1,25 @@ +return { + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + local lualine = require("lualine") + -- configure lualine with modified theme + lualine.setup({ + options = { + -- theme = "tokyonight", + -- theme = "catppuccin-mocha", + theme = "gruvbox-material", + }, + sections = { + lualine_c = { + { + "filename", + file_status = true, + path = 2, + }, + }, + }, + }) + end, +} + -- 2.30.2 From d3d7f6bd0ac662d7c2f5fd6ca015898bb0dc5835 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 11:48:49 +0300 Subject: [PATCH 20/41] Add trouble plugin --- lua/custom/plugins/trouble.lua | 10 ++++++++++ lua/custom/trouble.lua | 28 ++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 lua/custom/plugins/trouble.lua create mode 100644 lua/custom/trouble.lua diff --git a/lua/custom/plugins/trouble.lua b/lua/custom/plugins/trouble.lua new file mode 100644 index 0000000..fe73a96 --- /dev/null +++ b/lua/custom/plugins/trouble.lua @@ -0,0 +1,10 @@ +return { + { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + config = function() + require "custom/trouble" + end, + }, +} diff --git a/lua/custom/trouble.lua b/lua/custom/trouble.lua new file mode 100644 index 0000000..019be4f --- /dev/null +++ b/lua/custom/trouble.lua @@ -0,0 +1,28 @@ +local trouble = require("trouble") + +-- Setup Trouble +trouble.setup() + +-- Keybindings +vim.keymap.set("n", "xx", "Trouble diagnostics toggle", { desc = "Diagnostics (Trouble)" }) +vim.keymap.set("n", "xX", "Trouble diagnostics toggle filter.buf=0", + { desc = "Buffer Diagnostics (Trouble)" }) +vim.keymap.set("n", "cs", "Trouble symbols toggle focus=false", { desc = "Symbols (Trouble)" }) +vim.keymap.set("n", "cl", "Trouble lsp toggle focus=false win.position=right", + { desc = "LSP Definitions / references / ... (Trouble)" }) +vim.keymap.set("n", "xL", "Trouble loclist toggle", { desc = "Location List (Trouble)" }) +vim.keymap.set("n", "xQ", "Trouble qflist toggle", { desc = "Quickfix List (Trouble)" }) + +-- Telescope integration +local actions = require("telescope.actions") +local open_with_trouble = require("trouble.sources.telescope").open +local add_to_trouble = require("trouble.sources.telescope").add + +require("telescope").setup({ + defaults = { + mappings = { + i = { [""] = open_with_trouble }, + n = { [""] = open_with_trouble }, + }, + }, +}) -- 2.30.2 From e1dec1ee53181cd7f70c2ba76e093797cda35386 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 11:50:28 +0300 Subject: [PATCH 21/41] Add which_key plugin --- lua/custom/plugins/which_key.lua | 20 ++++++++++++++++++++ lua/custom/trouble.lua | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 lua/custom/plugins/which_key.lua diff --git a/lua/custom/plugins/which_key.lua b/lua/custom/plugins/which_key.lua new file mode 100644 index 0000000..f2cff19 --- /dev/null +++ b/lua/custom/plugins/which_key.lua @@ -0,0 +1,20 @@ +return { + "folke/which-key.nvim", + -- Telling nvim that it can load this plugin later, and that it is not + -- that important for initial UI + event = "VeryLazy", + -- Function that will run while neovim startup instead of when plugin is actualy loads + init = function() + -- How long which-key will wait until activation + vim.o.timeout = true + vim.o.timeoutlen = 500 + end, + -- Options that will pass to setup function, but we are leaving it empty to use + -- default configuration + opts = { + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } +} + diff --git a/lua/custom/trouble.lua b/lua/custom/trouble.lua index 019be4f..e22abbc 100644 --- a/lua/custom/trouble.lua +++ b/lua/custom/trouble.lua @@ -14,9 +14,9 @@ vim.keymap.set("n", "xL", "Trouble loclist toggle", { desc = "L vim.keymap.set("n", "xQ", "Trouble qflist toggle", { desc = "Quickfix List (Trouble)" }) -- Telescope integration -local actions = require("telescope.actions") +-- local actions = require("telescope.actions") local open_with_trouble = require("trouble.sources.telescope").open -local add_to_trouble = require("trouble.sources.telescope").add +-- local add_to_trouble = require("trouble.sources.telescope").add require("telescope").setup({ defaults = { -- 2.30.2 From ad9c779b205981495bde3f676c7e0fe67493f87e Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 17:02:46 +0300 Subject: [PATCH 22/41] Add basic luasnip config --- init.lua | 4 ++-- lua/custom/completion.lua | 22 ++++++++++++++++++++++ lua/custom/luasnip.lua | 33 +++++++++++++++++++++++++++++++++ lua/custom/plugins/luasnip.lua | 9 +++++++++ lua/custom/snippets/lua.lua | 10 ++++++++++ plugin/keymaps.lua | 2 +- 6 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 lua/custom/luasnip.lua create mode 100644 lua/custom/plugins/luasnip.lua create mode 100644 lua/custom/snippets/lua.lua diff --git a/init.lua b/init.lua index 8b6bc7e..f5883da 100644 --- a/init.lua +++ b/init.lua @@ -1,7 +1,7 @@ -- Making leader () key to space -vim.g.mapleader = "," +vim.g.mapleader = "\\" -- Making local leader () key to backslash -vim.g.maplocalleader = "\\" +vim.g.maplocalleader = "" -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" diff --git a/lua/custom/completion.lua b/lua/custom/completion.lua index 72cb31e..ab16127 100644 --- a/lua/custom/completion.lua +++ b/lua/custom/completion.lua @@ -3,6 +3,10 @@ -- menu: Show menu when completions available (more than 1) -- menuone: Show menu even when there is only 1 option -- noselect: Force user to select convinient option + +-- Load luasnip setup +require "custom.luasnip" + vim.opt.completeopt = { "menu", "menuone", "noselect" } local lspkind = require "lspkind" @@ -25,6 +29,7 @@ local cmp = require "cmp" cmp.setup { sources = { + { name = "luasnip" }, { name = "nvim_lsp" }, { name = "path" }, { name = "buffer" }, @@ -40,4 +45,21 @@ cmp.setup { { "i", "c" } ), }, + + -- Enable luasnip to handle snippet expansion for nvim-cmp + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + + formatting = { + fields = { "abbr", "kind", "menu" }, + expandable_indicator = true, + format = function(entry, vim_item) + -- Lspkind setup for icons + vim_item = kind_formatter(entry, vim_item) + return vim_item + end, + }, } diff --git a/lua/custom/luasnip.lua b/lua/custom/luasnip.lua new file mode 100644 index 0000000..99235c6 --- /dev/null +++ b/lua/custom/luasnip.lua @@ -0,0 +1,33 @@ +local ls = require "luasnip" +local types = require "luasnip.util.types" + +ls.config.set_config { + history = true, + updateevents = "TextChanged, TextChangedI", + enable_autosnippets = true +} + +vim.keymap.set({ "i", "s" }, "", function() + if ls.expand_or_jumpable() then + ls.expand_or_jump() + end +end, { silent = true }) + +vim.keymap.set({ "i", "s" }, "", function() + if ls.jumpable() then + ls.jump(-1) + end +end, { silent = true }) + +vim.keymap.set({ "i", "s" }, "", function() + if ls.choice_active() then + ls.change_choice(1) + end +end, { silent = true }) + +vim.keymap.set("n", "s", "source ~/.config/nvim_dev/lua/custom/luasnip.lua") + +-- Load custom snippets +for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/custom/snippets/*.lua", true)) do + loadfile(ft_path)() +end diff --git a/lua/custom/plugins/luasnip.lua b/lua/custom/plugins/luasnip.lua new file mode 100644 index 0000000..99006fc --- /dev/null +++ b/lua/custom/plugins/luasnip.lua @@ -0,0 +1,9 @@ +return { + { + "L3MON4D3/LuaSnip", + -- follow latest release. + version = "v2.*", -- Replace by the latest released major (first number of latest release) + -- install jsregexp (optional!). + build = "make install_jsregexp" + } +} diff --git a/lua/custom/snippets/lua.lua b/lua/custom/snippets/lua.lua new file mode 100644 index 0000000..166600a --- /dev/null +++ b/lua/custom/snippets/lua.lua @@ -0,0 +1,10 @@ +local ls = require "luasnip" + + +print("hello from lua snips") + +ls.add_snippets("lua", { + ls.parser.parse_snippet("expand", "-- this is what was expanded kek"), + ls.parser.parse_snippet("pipa", "Pipasik"), +}) + diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua index 5af4f86..70d3e45 100644 --- a/plugin/keymaps.lua +++ b/plugin/keymaps.lua @@ -7,5 +7,5 @@ set("n", "", "") set("n", "", "") -- Bindings for reloading LUA files (used when working with lua files) -set("n", "x", ".lua", { desc = "Execute the current lne" }) +-- set("n", "x", ".lua", { desc = "Execute the current lne" }) set("n", "x", "source %", { desc = "Execute the current file" }) -- 2.30.2 From 21403a7774bd505c9a67e46bb9dc985c5210a153 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sat, 1 Feb 2025 18:05:45 +0300 Subject: [PATCH 23/41] Add some other things for luasnip --- DESCRIPTION.md | 0 lua/custom/luasnip.lua | 2 +- lua/custom/plugins/tmux_navigator.lua | 18 ++++++++++++++++++ lua/custom/snippets/lua.lua | 7 +++---- lua/custom/snippets/python.lua | 9 +++++++++ plugin/keymaps.lua | 8 ++++---- 6 files changed, 35 insertions(+), 9 deletions(-) delete mode 100644 DESCRIPTION.md create mode 100644 lua/custom/plugins/tmux_navigator.lua create mode 100644 lua/custom/snippets/python.lua diff --git a/DESCRIPTION.md b/DESCRIPTION.md deleted file mode 100644 index e69de29..0000000 diff --git a/lua/custom/luasnip.lua b/lua/custom/luasnip.lua index 99235c6..e6917c7 100644 --- a/lua/custom/luasnip.lua +++ b/lua/custom/luasnip.lua @@ -25,7 +25,7 @@ vim.keymap.set({ "i", "s" }, "", function() end end, { silent = true }) -vim.keymap.set("n", "s", "source ~/.config/nvim_dev/lua/custom/luasnip.lua") +vim.keymap.set("n", "s", "source ~/.config/nvim/lua/custom/luasnip.lua") -- Load custom snippets for _, ft_path in ipairs(vim.api.nvim_get_runtime_file("lua/custom/snippets/*.lua", true)) do diff --git a/lua/custom/plugins/tmux_navigator.lua b/lua/custom/plugins/tmux_navigator.lua new file mode 100644 index 0000000..e7fa738 --- /dev/null +++ b/lua/custom/plugins/tmux_navigator.lua @@ -0,0 +1,18 @@ +return { + "christoomey/vim-tmux-navigator", + cmd = { + "TmuxNavigateLeft", + "TmuxNavigateDown", + "TmuxNavigateUp", + "TmuxNavigateRight", + "TmuxNavigatePrevious", + }, + keys = { + { "", "TmuxNavigateLeft" }, + { "", "TmuxNavigateDown" }, + { "", "TmuxNavigateUp" }, + { "", "TmuxNavigateRight" }, + { "", "TmuxNavigatePrevious" }, + }, +} + diff --git a/lua/custom/snippets/lua.lua b/lua/custom/snippets/lua.lua index 166600a..eaefb80 100644 --- a/lua/custom/snippets/lua.lua +++ b/lua/custom/snippets/lua.lua @@ -1,10 +1,9 @@ +-- Clear snippets collection when souring lua file +require("luasnip.session.snippet_collection").clear_snippets "lua" + local ls = require "luasnip" - -print("hello from lua snips") - ls.add_snippets("lua", { ls.parser.parse_snippet("expand", "-- this is what was expanded kek"), ls.parser.parse_snippet("pipa", "Pipasik"), }) - diff --git a/lua/custom/snippets/python.lua b/lua/custom/snippets/python.lua new file mode 100644 index 0000000..eaefb80 --- /dev/null +++ b/lua/custom/snippets/python.lua @@ -0,0 +1,9 @@ +-- Clear snippets collection when souring lua file +require("luasnip.session.snippet_collection").clear_snippets "lua" + +local ls = require "luasnip" + +ls.add_snippets("lua", { + ls.parser.parse_snippet("expand", "-- this is what was expanded kek"), + ls.parser.parse_snippet("pipa", "Pipasik"), +}) diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua index 70d3e45..3918500 100644 --- a/plugin/keymaps.lua +++ b/plugin/keymaps.lua @@ -1,10 +1,10 @@ local set = vim.keymap.set -- Basic movement keybinds, these make navigating splits easy for me -set("n", "", "") -set("n", "", "") -set("n", "", "") -set("n", "", "") +-- set("n", "", "") +-- set("n", "", "") +-- set("n", "", "") +-- set("n", "", "") -- Bindings for reloading LUA files (used when working with lua files) -- set("n", "x", ".lua", { desc = "Execute the current lne" }) -- 2.30.2 From d2239e1e962a0723643889b43e4fe57c4d168d5e Mon Sep 17 00:00:00 2001 From: ashalimov Date: Sat, 1 Feb 2025 19:10:39 +0300 Subject: [PATCH 24/41] Make enhancement for Astra --- lua/custom/lsp.lua | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua index f0eb875..c04577a 100644 --- a/lua/custom/lsp.lua +++ b/lua/custom/lsp.lua @@ -84,16 +84,29 @@ end, vim.tbl_keys(servers)) require("mason").setup() local ensure_installed = { + -- Normal settings "stylua", "lua_ls", - "ruff", - "gopls", "gofumpt", "golines", "prettier", - "pyright" } +-- Now we need to make things work in Astra +-- Main Astra cockblock - low python version, that prevents installation of +-- some modules, so in order to prevent mason from whining - disable some +-- autoinstall modules depending on currently installed python version +-- NOTE: You must install removed dependencies manually +local python_version = io.popen("python --version"):read("*a") +local _, minor, _ = python_version:match("Python (%d+)%.(%d+)%.(%d+)") +if tonumber(minor) < 8 then + for i, k in pairs(servers_to_install) do + -- Ruff is not supported for python lower than 3.8 + if k == "ruff" then + table.remove(servers_to_install, i) + end + end +end vim.list_extend(ensure_installed, servers_to_install) require("mason-tool-installer").setup { ensure_installed = ensure_installed } @@ -108,17 +121,6 @@ for name, config in pairs(servers) do lspconfig[name].setup(config) end -for name, config in pairs(servers) do - if config == true then - config = {} - end - config = vim.tbl_deep_extend("force", {}, { - capabilities = capabilities, - }, config) - - lspconfig[name].setup(config) -end - -- Here it is used the LSP server attaches to file vim.api.nvim_create_autocmd("LspAttach", { -- Grouping together autocommands. -- 2.30.2 From 02246c2385cde5ddf68a91c9b6bc13c68ccf6ec7 Mon Sep 17 00:00:00 2001 From: ashalimov Date: Sat, 1 Feb 2025 23:26:39 +0300 Subject: [PATCH 25/41] Add some python snippets --- lua/custom/snippets/python.lua | 57 +++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/lua/custom/snippets/python.lua b/lua/custom/snippets/python.lua index eaefb80..e1a25ec 100644 --- a/lua/custom/snippets/python.lua +++ b/lua/custom/snippets/python.lua @@ -1,9 +1,58 @@ -- Clear snippets collection when souring lua file -require("luasnip.session.snippet_collection").clear_snippets "lua" +require("luasnip.session.snippet_collection").clear_snippets "python" local ls = require "luasnip" -ls.add_snippets("lua", { - ls.parser.parse_snippet("expand", "-- this is what was expanded kek"), - ls.parser.parse_snippet("pipa", "Pipasik"), +local s = ls.snippet +local t = ls.text_node +local i = ls.insert_node + +local fmt = require("luasnip.extras.fmt").fmt +local rep = require("luasnip.extras").rep + +ls.add_snippets("python", { + s({ trig = "implog", dscr = "Import necessary logging utils" }, { + t({ + "import logging", + "_log = logging.getLogger(__name__)" + } + ) + }), + s({ trig = "logevent", dscr = "Import necessary logging utils" }, + fmt( + [[ + _log.error('{}' * 60)) + _log.error({}) + _log.error('{}' * 60)) + ]], + { i(1), i(2), rep(1) } + ) + ), + s({ trig = "pybasetest", dscr = "Create test suite boilerplate" }, + fmt( + [[ + class Test{}: + """Test suite for checking correct work of {} feature""" + + @pytest.fixture(autouse=True) + def setup_test(self): + """Fixture for initializing test cases base data""" + {} + + {} + ]], + { i(1), rep(1), i(2), i(0) } + ) + ), + s({ trig = "pysection", dscr = "Secion snippet" }, + fmt( + [[ + ##################### Section ############################## + # Section topic: {} + ############################################################ + {} + ]], + { i(1), i(0) } + ) + ), }) -- 2.30.2 From 97a0858e3398f16171c28f7c7e3638b81fc2e4ac Mon Sep 17 00:00:00 2001 From: ashalimov Date: Sun, 2 Feb 2025 00:41:42 +0300 Subject: [PATCH 26/41] Make some MORE snippets for python --- lua/custom/luasnip.lua | 3 ++- lua/custom/snippets/python.lua | 42 ++++++++++++++++++++++++++++++---- 2 files changed, 40 insertions(+), 5 deletions(-) diff --git a/lua/custom/luasnip.lua b/lua/custom/luasnip.lua index e6917c7..2c6820f 100644 --- a/lua/custom/luasnip.lua +++ b/lua/custom/luasnip.lua @@ -4,7 +4,8 @@ local types = require "luasnip.util.types" ls.config.set_config { history = true, updateevents = "TextChanged, TextChangedI", - enable_autosnippets = true + enable_autosnippets = true, + store_selection_keys = "", } vim.keymap.set({ "i", "s" }, "", function() diff --git a/lua/custom/snippets/python.lua b/lua/custom/snippets/python.lua index e1a25ec..8540877 100644 --- a/lua/custom/snippets/python.lua +++ b/lua/custom/snippets/python.lua @@ -6,11 +6,38 @@ local ls = require "luasnip" local s = ls.snippet local t = ls.text_node local i = ls.insert_node +local c = ls.choice_node +local f = ls.function_node local fmt = require("luasnip.extras.fmt").fmt +local fmta = require("luasnip.extras.fmt").fmta local rep = require("luasnip.extras").rep ls.add_snippets("python", { + s({ trig = "cmethod", dscr = "Create method or function with test stub" }, + fmta( + [[ + def <>(): + """<> for performing <>""" + pass + + def test_<>_<>(): + """Test for checking correct work of <> <>""" + assert 1 == 2 + <> + ]], + { + i(1), + c(2, { t "Function", t "Method" }), + i(3), + rep(1), + f(function(args) return string.lower(args[1][1]) end, { 2 }), + rep(1), + f(function(args) return string.lower(args[1][1]) end, { 2 }), + i(0) + } + ) + ), s({ trig = "implog", dscr = "Import necessary logging utils" }, { t({ "import logging", @@ -21,11 +48,18 @@ ls.add_snippets("python", { s({ trig = "logevent", dscr = "Import necessary logging utils" }, fmt( [[ - _log.error('{}' * 60)) - _log.error({}) - _log.error('{}' * 60)) + _log.{}('{}' * 60)) + _log.{}({}) + _log.{}('{}' * 60)) ]], - { i(1), i(2), rep(1) } + { + c(1, { t "error", t "warning", t "info" }), + i(2), + rep(1), + i(3), + rep(1), + rep(2) + } ) ), s({ trig = "pybasetest", dscr = "Create test suite boilerplate" }, -- 2.30.2 From dec7cb040d9b567010f5b3b412a7a3305eca6288 Mon Sep 17 00:00:00 2001 From: ashalimov Date: Sun, 2 Feb 2025 00:47:27 +0300 Subject: [PATCH 27/41] Add snippets README --- lua/custom/snippets/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 lua/custom/snippets/README.md diff --git a/lua/custom/snippets/README.md b/lua/custom/snippets/README.md new file mode 100644 index 0000000..5eb0b03 --- /dev/null +++ b/lua/custom/snippets/README.md @@ -0,0 +1,20 @@ +# Гайд по формированию сниппетов +## fmta + f +Рассмотрим пример использования `fmta` в сочетании с `f`: +``` +f(function(args) return string.lower(args[1][1]) end, {1}) +``` +Тут: +- `f`: Это функция LuaSnip, которая позволяет выполнять произвольные преобразования над входными данными. + Она принимает два аргумента: + - Функцию, которая выполняет преобразование. + - Список индексов, указывающих, какие входные данные использовать. + +- `function(args)`: Это функция, которая принимает аргумент args — таблица, содержащая значения, переданные из других узлов (например, i(1), i(2) и т.д.). +- `args[1][1]`: + - `args[1]` — это первая группа входных данных, переданная в f. + - `args[1][1]` — это первое значение из этой группы. Например, если вы используете i(1), то args[1][1] будет содержать текст, введенный пользователем для этого узла. + +- `string.lower(args[1][1])`: `string.lower` — это стандартная функция Lua, которая преобразует строку в нижний регистр. + +- `{1}`: Это список индексов, указывающих, какие входные данные использовать. `{1}` означает, что функция будет использовать значение из первого узла (например, i(1)). -- 2.30.2 From 29884f0e0ca8c4e53940c5d81dafa14c44389044 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sun, 2 Feb 2025 15:54:21 +0300 Subject: [PATCH 28/41] Update binding for snippets and refactor python version getter --- lua/custom/README.md | 59 ++++++++++++++++++++++++++++++++++++++++++ lua/custom/lsp.lua | 38 ++++++++++++++++++++++++--- lua/custom/luasnip.lua | 4 +-- plugin/options.lua | 8 +++--- 4 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 lua/custom/README.md diff --git a/lua/custom/README.md b/lua/custom/README.md new file mode 100644 index 0000000..d725dd7 --- /dev/null +++ b/lua/custom/README.md @@ -0,0 +1,59 @@ +# Справка по интересным моментам в коде +## Функция получения версии `python` в `lsp.lua` + +```lua +local function get_python_version() + local handle = io.popen("python --version 2>&1") -- Redirect stderr to stdout + if handle then + local result = handle:read("*a") + handle:close() + -- Check if the output contains a version number + local version = result:match("Python (%d+%.%d+%.%d+)") + if version then + return version + end + end + + handle = io.popen("python3 --version 2>&1") -- Redirect stderr to stdout + if handle then + local result = handle:read("*a") + handle:close() + -- Check if the output contains a version number + local version = result:match("Python (%d+%.%d+%.%d+)") + if version then + return version + end + end + -- TODO: Add some exception handling if python not installed on user machine + return "Python 0.0.0" +end +``` +Что тут есть примечательного: +- Получение данных, выполняя команду в shell оболочке системы с помощью + `io.popen`. *Важно*: Данная функция может работать не во всех ОС +- Функция выполняет команду, указанную в аргументе, и возвращает *файловый + дескриптор*, который можно использовать для чтения вывода команды (или + записи в нее) + +Разберем флоу подробнее: +Если про `python --version` - все понятно, то вот: +```lua +2>&1 +``` +Уже надо прояснить: +- В UNIX-подобных системах есть три стандартных потока - `stdin` = 0; `stdout` = 1; + `strerr` = 2; +- По умолчанию `io.popen` передает только вывод `stdout` в handle, поэтому для обработки +ошибок, надо дополнительно захватывать поток `stderr` +- `2>&1` означает, что мы хотим перенаправить поток ошибок 2 в стандартный вывод 1; +- Это нужно для того, чтобы захватить не только вывод команды, но и возможные ошибки +(например если питон не установлен); +- `>&` - оператор перенаправления потоков. + +Дополнительно: +`*a` внутри `read` - конструкция формата чтения файловых объектов в `Lua`. Они +указывают - как именно стоит читать данные из файла или потока. Помимо `a` есть +еще: +- `*a` - читать все содержимое +- `*l` - читать строку +- `*n` - читать число. diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua index c04577a..00ccedc 100644 --- a/lua/custom/lsp.lua +++ b/lua/custom/lsp.lua @@ -92,13 +92,43 @@ local ensure_installed = { "prettier", } +local function get_python_version() + local handle = io.popen("python --version 2>&1") -- Redirect stderr to stdout + if handle then + local result = handle:read("*a") + handle:close() + -- Check if the output contains a version number + local version = result:match("Python (%d+%.%d+%.%d+)") + if version then + return version + end + end + + handle = io.popen("python3 --version 2>&1") -- Redirect stderr to stdout + if handle then + local result = handle:read("*a") + handle:close() + -- Check if the output contains a version number + local version = result:match("Python (%d+%.%d+%.%d+)") + if version then + return version + end + end + -- TODO: Add some exception handling if python not installed on user machine + return "Python 0.0.0" +end + -- Now we need to make things work in Astra --- Main Astra cockblock - low python version, that prevents installation of --- some modules, so in order to prevent mason from whining - disable some +-- Main Astra cockblock - low python version, that prevents installation of +-- some modules, so in order to prevent mason from whining - disable some -- autoinstall modules depending on currently installed python version -- NOTE: You must install removed dependencies manually -local python_version = io.popen("python --version"):read("*a") -local _, minor, _ = python_version:match("Python (%d+)%.(%d+)%.(%d+)") +local python_version = get_python_version() +print(python_version) +if python_version == nil then + python_version = "Python 3.13" +end +local _, minor, _ = python_version:match(".*(%d+)%.(%d+)%.(%d+)") if tonumber(minor) < 8 then for i, k in pairs(servers_to_install) do -- Ruff is not supported for python lower than 3.8 diff --git a/lua/custom/luasnip.lua b/lua/custom/luasnip.lua index 2c6820f..9b98678 100644 --- a/lua/custom/luasnip.lua +++ b/lua/custom/luasnip.lua @@ -8,13 +8,13 @@ ls.config.set_config { store_selection_keys = "", } -vim.keymap.set({ "i", "s" }, "", function() +vim.keymap.set({ "i", "s" }, "", function() if ls.expand_or_jumpable() then ls.expand_or_jump() end end, { silent = true }) -vim.keymap.set({ "i", "s" }, "", function() +vim.keymap.set({ "i", "s" }, "", function() if ls.jumpable() then ls.jump(-1) end diff --git a/plugin/options.lua b/plugin/options.lua index 36a9696..f0e1dae 100644 --- a/plugin/options.lua +++ b/plugin/options.lua @@ -3,7 +3,7 @@ local opt = vim.opt -- Command to show inline what are you trying to perform opt.inccommand = "split" --- Search settings to toggle "smart case" search only if 1+ uppercase char +-- Search settings to toggle "smart case" search only if 1+ uppercase char -- persist in search line opt.smartcase = true opt.ignorecase = true @@ -13,8 +13,8 @@ opt.number = true opt.relativenumber = true -- Tabulation and indentation settings -opt.shiftwidth = 2 -- Set spaces for tabs == 2 -opt.tabstop = 2 -- Set spaces for indent with == 2 +opt.shiftwidth = 2 -- Set spaces for tabs == 2 +opt.tabstop = 2 -- Set spaces for indent with == 2 opt.expandtab = true -- use number of spaces to insert a opt.softtabstop = 2 @@ -24,3 +24,5 @@ opt.swapfile = false -- Add line at 80 symbols opt.colorcolumn = "80" +-- config to set up clipboard as default register +opt.clipboard:append("unnamedplus") -- 2.30.2 From 88b0c1ffc2098ea55bb9fa6fa444c37c35e9811d Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sun, 2 Feb 2025 15:58:28 +0300 Subject: [PATCH 29/41] Add python snippet for creating sqlalchemy table --- lua/custom/snippets/python.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lua/custom/snippets/python.lua b/lua/custom/snippets/python.lua index 8540877..88fcb42 100644 --- a/lua/custom/snippets/python.lua +++ b/lua/custom/snippets/python.lua @@ -14,6 +14,24 @@ local fmta = require("luasnip.extras.fmt").fmta local rep = require("luasnip.extras").rep ls.add_snippets("python", { + s( + { trig = "ctable", dscr = "Create method or function with test stub" }, + fmt( + [[ + {} = Table( + "{}", + metadata_obj, + Column("id", Integer, primary_key=True), + {} + ) + ]], + { + i(1), + rep(1), + i(0) + } + ) + ), s({ trig = "cmethod", dscr = "Create method or function with test stub" }, fmta( [[ -- 2.30.2 From 3af760037900991f2f056e12889197608b3fa35e Mon Sep 17 00:00:00 2001 From: pro100ton Date: Sun, 2 Feb 2025 18:05:53 +0300 Subject: [PATCH 30/41] Remove prints --- ftplugin/go.lua | 1 - lua/custom/lsp.lua | 1 - 2 files changed, 2 deletions(-) diff --git a/ftplugin/go.lua b/ftplugin/go.lua index 1473193..e69de29 100644 --- a/ftplugin/go.lua +++ b/ftplugin/go.lua @@ -1 +0,0 @@ -print("Hello from golang file") diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua index 00ccedc..8b4dc8b 100644 --- a/lua/custom/lsp.lua +++ b/lua/custom/lsp.lua @@ -124,7 +124,6 @@ end -- autoinstall modules depending on currently installed python version -- NOTE: You must install removed dependencies manually local python_version = get_python_version() -print(python_version) if python_version == nil then python_version = "Python 3.13" end -- 2.30.2 From f0fe804630f619636cb03752a3769797c1ccbede Mon Sep 17 00:00:00 2001 From: ashalimov Date: Mon, 3 Feb 2025 09:00:33 +0300 Subject: [PATCH 31/41] Change path display for telescope --- lua/custom/plugins/telescope.lua | 20 ++++++++++---------- lua/custom/telescope.lua | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua index d2c6291..2575d64 100644 --- a/lua/custom/plugins/telescope.lua +++ b/lua/custom/plugins/telescope.lua @@ -1,12 +1,12 @@ return { - "nvim-telescope/telescope.nvim", - dependencies = { - { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, - "nvim-lua/plenary.nvim", - "nvim-tree/nvim-web-devicons", - "folke/todo-comments.nvim", - }, - config = function() - require "custom.telescope" - end, + "nvim-telescope/telescope.nvim", + dependencies = { + { "nvim-telescope/telescope-fzf-native.nvim", build = "make" }, + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "folke/todo-comments.nvim", + }, + config = function() + require "custom.telescope" + end } diff --git a/lua/custom/telescope.lua b/lua/custom/telescope.lua index 0ea13f1..e9198d5 100644 --- a/lua/custom/telescope.lua +++ b/lua/custom/telescope.lua @@ -1,6 +1,6 @@ require("telescope").setup { defaults = { - path_display = { "smart" }, + path_display = { shorten = 4 }, }, } -- 2.30.2 From a28b24c94312b3219f8b2b53e112304889c8e610 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Mon, 3 Feb 2025 20:55:31 +0300 Subject: [PATCH 32/41] Add obsidian plugin --- lua/custom/obsidian.lua | 64 +++++++++++++++++++++++++++++++++ lua/custom/oil.lua | 51 +++++++++++++------------- lua/custom/plugins/obsidian.lua | 12 +++++++ 3 files changed, 101 insertions(+), 26 deletions(-) create mode 100644 lua/custom/obsidian.lua create mode 100644 lua/custom/plugins/obsidian.lua diff --git a/lua/custom/obsidian.lua b/lua/custom/obsidian.lua new file mode 100644 index 0000000..fa1f09f --- /dev/null +++ b/lua/custom/obsidian.lua @@ -0,0 +1,64 @@ +require("obsidian").setup { + -- Set workspace setting + workspaces = { + { + name = "personal", + path = "~/Documents/t0xa_vault", + } + }, + -- Disable conceal level to supress varning log message + ui = { + enable = false + }, + -- Set notes subdir to store new notes + notes_subdir = "Unsorted", + new_notes_location = "notes_subdir", + -- Set template params + templates = { + folder = "Templates", + date_format = "%Y-%m-%d", + time_format = "%H:%M", + substitutions = { + yesterday = function() + return os.date("%Y-%m-%d", os.time() - 86400) + end + } + }, + -- Set behaviour of following links + follow_url_func = function(url) + -- vim.fn.jobstart({ "open", url }) -- Mac OS + vim.fn.jobstart({ "xdg-open", url }) -- linux + -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows + -- vim.ui.open(url) -- need Neovim 0.10.0+ + end, + -- Set behaviour for opening images + follow_img_func = function(img) + -- vim.fn.jobstart { "qlmanage", "-p", img } -- Mac OS quick look preview + vim.fn.jobstart({ "xdg-open", url }) -- linux + -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows + end, + -- Set sorting for creation date + sort_by = "created", + -- Set attachements new folder + attachments = { + img_folder = "Media" + } +} + + +-- Obsidian-related keybinds +vim.keymap.set("n", "oit", "ObsidianTemplate", + { silent = true, noremap = true, desc = "Obsidian: insert template" }) +vim.keymap.set("n", "oo", "ObsidianQuickSwitch", + { silent = true, noremap = true, desc = "Obsidian: open file" }) +vim.keymap.set("n", "opi", "ObsidianPasteImg", + { silent = true, noremap = true, desc = "Obsidian: paste image" }) +vim.keymap.set("n", "or", "ObsidianRename", + { silent = true, noremap = true, desc = "Obsidian: rename file" }) +vim.keymap.set("n", "ol", "ObsidianToggleCheckbox", + { silent = true, noremap = true, desc = "Obsidian: toggle checkbox" }) +vim.keymap.set("n", "on", "ObsidianNew", { silent = true, noremap = true, desc = "Obsidian: new file" }) +vim.keymap.set("n", "otoc", "ObsidianTOC", + { silent = true, noremap = true, desc = "Obsidian: open TOC" }) +vim.keymap.set("n", "ofl", "ObsidianFollowLink", + { silent = true, noremap = true, desc = "Obsidian: follow link" }) diff --git a/lua/custom/oil.lua b/lua/custom/oil.lua index 0b43a33..865c855 100644 --- a/lua/custom/oil.lua +++ b/lua/custom/oil.lua @@ -1,27 +1,26 @@ -require("oil").setup{ - opts = { - keymaps = { - ["g?"] = "actions.show_help", - [""] = "actions.select", - [""] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" }, - [""] = false, - [""] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" }, - [""] = "actions.preview", - [""] = "actions.close", - [""] = false, - ["-"] = "actions.parent", - ["_"] = "actions.open_cwd", - ["`"] = "actions.cd", - ["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory", mode = "n" }, - ["gs"] = "actions.change_sort", - ["gx"] = "actions.open_external", - ["g."] = "actions.toggle_hidden", - ["g\\"] = "actions.toggle_trash", - }, - view_options = { - show_hidden = true, - }, - }, - -- Open parent directory in current window - vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }), +require("oil").setup { + keymaps = { + ["g?"] = "actions.show_help", + [""] = "actions.select", + [""] = { "actions.select", opts = { vertical = true }, desc = "Open the entry in a vertical split" }, + [""] = false, + [""] = { "actions.select", opts = { tab = true }, desc = "Open the entry in new tab" }, + [""] = "actions.preview", + [""] = "actions.close", + [""] = false, + ["-"] = "actions.parent", + ["_"] = "actions.open_cwd", + ["`"] = "actions.cd", + ["~"] = { "actions.cd", opts = { scope = "tab" }, desc = ":tcd to the current oil directory", mode = "n" }, + ["gs"] = "actions.change_sort", + ["gx"] = "actions.open_external", + ["g."] = "actions.toggle_hidden", + ["g\\"] = "actions.toggle_trash", + }, + view_options = { + show_hidden = true, + }, + -- Open parent directory in current window } + +vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) diff --git a/lua/custom/plugins/obsidian.lua b/lua/custom/plugins/obsidian.lua new file mode 100644 index 0000000..849fa2a --- /dev/null +++ b/lua/custom/plugins/obsidian.lua @@ -0,0 +1,12 @@ +return { + "epwalsh/obsidian.nvim", + version = "*", + lazy = true, + ft = "markdown", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + require "custom.obsidian" + end +} -- 2.30.2 From abc258d4840b083ffd8e4a8200f5df2c558467a4 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Mon, 3 Feb 2025 20:57:11 +0300 Subject: [PATCH 33/41] Add obsidian bind for tags list --- lua/custom/obsidian.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lua/custom/obsidian.lua b/lua/custom/obsidian.lua index fa1f09f..a01e4ee 100644 --- a/lua/custom/obsidian.lua +++ b/lua/custom/obsidian.lua @@ -62,3 +62,5 @@ vim.keymap.set("n", "otoc", "ObsidianTOC", { silent = true, noremap = true, desc = "Obsidian: open TOC" }) vim.keymap.set("n", "ofl", "ObsidianFollowLink", { silent = true, noremap = true, desc = "Obsidian: follow link" }) +vim.keymap.set("n", "otl", "ObsidianTags", + { silent = true, noremap = true, desc = "Obsidian: Get tags list" }) -- 2.30.2 From cb4c440d8c16af3e852a392369a7f6ef4264b46f Mon Sep 17 00:00:00 2001 From: pro100ton Date: Mon, 3 Feb 2025 21:02:11 +0300 Subject: [PATCH 34/41] Obsidian: Disable formatter --- lua/custom/obsidian.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lua/custom/obsidian.lua b/lua/custom/obsidian.lua index a01e4ee..57358ef 100644 --- a/lua/custom/obsidian.lua +++ b/lua/custom/obsidian.lua @@ -42,7 +42,9 @@ require("obsidian").setup { -- Set attachements new folder attachments = { img_folder = "Media" - } + }, + -- Disable auto formatter for files + disable_frontmatter = true, } -- 2.30.2 From db5e4477d122249225460f78047680f13d161cde Mon Sep 17 00:00:00 2001 From: pro100ton Date: Tue, 4 Feb 2025 09:10:38 +0300 Subject: [PATCH 35/41] Add some additional binding for obsidian --- lua/custom/obsidian.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lua/custom/obsidian.lua b/lua/custom/obsidian.lua index 57358ef..1d02283 100644 --- a/lua/custom/obsidian.lua +++ b/lua/custom/obsidian.lua @@ -57,12 +57,16 @@ vim.keymap.set("n", "opi", "ObsidianPasteImg", { silent = true, noremap = true, desc = "Obsidian: paste image" }) vim.keymap.set("n", "or", "ObsidianRename", { silent = true, noremap = true, desc = "Obsidian: rename file" }) -vim.keymap.set("n", "ol", "ObsidianToggleCheckbox", +vim.keymap.set("n", "oc", "ObsidianToggleCheckbox", { silent = true, noremap = true, desc = "Obsidian: toggle checkbox" }) vim.keymap.set("n", "on", "ObsidianNew", { silent = true, noremap = true, desc = "Obsidian: new file" }) vim.keymap.set("n", "otoc", "ObsidianTOC", { silent = true, noremap = true, desc = "Obsidian: open TOC" }) vim.keymap.set("n", "ofl", "ObsidianFollowLink", { silent = true, noremap = true, desc = "Obsidian: follow link" }) -vim.keymap.set("n", "otl", "ObsidianTags", +vim.keymap.set("n", "olt", "ObsidianTags", { silent = true, noremap = true, desc = "Obsidian: Get tags list" }) +vim.keymap.set("n", "osb", "ObsidianBacklinks", + { silent = true, noremap = true, desc = "Obsidian: Show Backlinks" }) +vim.keymap.set("n", "osl", "ObsidianLinks", + { silent = true, noremap = true, desc = "Obsidian: Show Links" }) -- 2.30.2 From 82084adcb72472d329b1d8378d260dcff83b0292 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Thu, 6 Feb 2025 08:23:43 +0300 Subject: [PATCH 36/41] Add keymap for russian C-W functionality --- plugin/keymaps.lua | 4 ++++ plugin/options.lua | 1 + 2 files changed, 5 insertions(+) diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua index 3918500..44f5019 100644 --- a/plugin/keymaps.lua +++ b/plugin/keymaps.lua @@ -9,3 +9,7 @@ local set = vim.keymap.set -- Bindings for reloading LUA files (used when working with lua files) -- set("n", "x", ".lua", { desc = "Execute the current lne" }) set("n", "x", "source %", { desc = "Execute the current file" }) + +-- Following section purprose is to rebind some Russian missing binds +-- TODO: Maybe there is more clean and percise way, dunno right now +set("i", "", "") diff --git a/plugin/options.lua b/plugin/options.lua index f0e1dae..4b875ba 100644 --- a/plugin/options.lua +++ b/plugin/options.lua @@ -26,3 +26,4 @@ opt.colorcolumn = "80" -- config to set up clipboard as default register opt.clipboard:append("unnamedplus") + -- 2.30.2 From 6363a15c3ffd200f68bb47be352f55f3c53c5a59 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Thu, 6 Feb 2025 08:24:02 +0300 Subject: [PATCH 37/41] Enable pyrithgt --- lua/custom/lsp.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lua/custom/lsp.lua b/lua/custom/lsp.lua index 8b4dc8b..9498ec0 100644 --- a/lua/custom/lsp.lua +++ b/lua/custom/lsp.lua @@ -41,9 +41,9 @@ local servers = { python = { analysis = { -- Ignore all files for analysis to exclusively use Ruff for linting - ignore = { "*" }, + -- ignore = { "*" }, diagnosticMode = "off", - typeCheckingMode = "off", + -- typeCheckingMode = "off", }, }, }, -- 2.30.2 From 7eaa6551cbb5f7545048c438d32e9ef8ab34da6f Mon Sep 17 00:00:00 2001 From: ashalimov Date: Mon, 10 Feb 2025 09:21:11 +0300 Subject: [PATCH 38/41] Add setting to toggle obsidian plugin --- README.md | 12 +++++++++++- init.lua | 5 +++++ lua/custom/plugins/obsidian.lua | 28 ++++++++++++++++------------ 3 files changed, 32 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a63a611..e144f85 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,16 @@ require("oil").setup{ Тут храняться настройки, которые будут применены **до** загразуки плагинов. Т.е. настройки, что определны где-то в настройках плагинов будут переписывать если что те, которые установлены для типов файлов тут ### after/ftplugin Настройки для типов файлов тут будут применены уже после того, как загрузится все содержимое neovim => эти настройки будут перегружать все то, что было настроено в плагинах - +## Включение / Выключение некоторых плагинов +Из за возникновения случаев, когда некоторые плагины на некоторых машинах не нужно включать (например obsidian мне нужен только на хостовых машинах, на удаленных он будет только мешать открывать .md файлы), то в `init.lua` у меня в самом начале устанавливаются для таких плагинов глобальные переменные со следующей семантикой: +``` +vim.g._enabled = +``` +Например: +```lua +vim.g.obsidian_enabled = false +``` +Это позволяет динамически включать/выключать плагины без необходимости усложнять конфиг `lazy` # FAQ > Зачем так мучаться? Не проще все кидать в один файл? @@ -59,3 +68,4 @@ sudo apt install liblua5.3-dev ```js npm install -g tree-sitter-cli ``` + diff --git a/init.lua b/init.lua index f5883da..45408d8 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,7 @@ +-- Global settings params +--- Option to enable/disalbe obsidian plugin +vim.g.obsidian_enabled = false + -- Making leader () key to space vim.g.mapleader = "\\" -- Making local leader () key to backslash @@ -33,3 +37,4 @@ require("lazy").setup({ -- automatically check for plugin updates checker = { enabled = false }, }) + diff --git a/lua/custom/plugins/obsidian.lua b/lua/custom/plugins/obsidian.lua index 849fa2a..0f9377d 100644 --- a/lua/custom/plugins/obsidian.lua +++ b/lua/custom/plugins/obsidian.lua @@ -1,12 +1,16 @@ -return { - "epwalsh/obsidian.nvim", - version = "*", - lazy = true, - ft = "markdown", - dependencies = { - "nvim-lua/plenary.nvim", - }, - config = function() - require "custom.obsidian" - end -} +if vim.g.obsidian_enabled then + return { + "epwalsh/obsidian.nvim", + version = "*", + lazy = true, + ft = "markdown", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + require "custom.obsidian" + end + } +else + return {} +end -- 2.30.2 From 834038a59b84799c8d1456fa2eb221294d170ba5 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Tue, 11 Feb 2025 10:25:00 +0300 Subject: [PATCH 39/41] Move splitline from 80 to 99 symbols --- plugin/options.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/options.lua b/plugin/options.lua index 4b875ba..c95973e 100644 --- a/plugin/options.lua +++ b/plugin/options.lua @@ -22,7 +22,7 @@ opt.softtabstop = 2 opt.swapfile = false -- Add line at 80 symbols -opt.colorcolumn = "80" +opt.colorcolumn = "99" -- config to set up clipboard as default register opt.clipboard:append("unnamedplus") -- 2.30.2 From aa20450e895549215515bd09668eb22b6c15be09 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Thu, 20 Feb 2025 08:51:30 +0300 Subject: [PATCH 40/41] Set oil refresh button to [gr] --- lua/custom/oil.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/lua/custom/oil.lua b/lua/custom/oil.lua index 865c855..cf32130 100644 --- a/lua/custom/oil.lua +++ b/lua/custom/oil.lua @@ -16,6 +16,7 @@ require("oil").setup { ["gx"] = "actions.open_external", ["g."] = "actions.toggle_hidden", ["g\\"] = "actions.toggle_trash", + ["gr"] = "actions.refresh", }, view_options = { show_hidden = true, -- 2.30.2 From e4914f58dec1e3ab1e3e1bf736d1765a4a773343 Mon Sep 17 00:00:00 2001 From: pro100ton Date: Tue, 4 Mar 2025 12:59:51 +0300 Subject: [PATCH 41/41] Redo section snippets for python --- lua/custom/snippets/python.lua | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lua/custom/snippets/python.lua b/lua/custom/snippets/python.lua index 88fcb42..93626a1 100644 --- a/lua/custom/snippets/python.lua +++ b/lua/custom/snippets/python.lua @@ -96,12 +96,23 @@ ls.add_snippets("python", { { i(1), rep(1), i(2), i(0) } ) ), + s({ trig = "rupysection", dscr = "Secion snippet" }, + fmt( + [[ + ##################################### Секция ############################################# + # Тема: {} + ########################################################################################## + {} + ]], + { i(1), i(0) } + ) + ), s({ trig = "pysection", dscr = "Secion snippet" }, fmt( [[ - ##################### Section ############################## + ##################################### Section ############################################ # Section topic: {} - ############################################################ + ########################################################################################## {} ]], { i(1), i(0) } -- 2.30.2