From fb0185df65d262a39979c53aa7ce986506fe6186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A7=D0=B5=D1=80=D0=BD=D0=B8=D0=B3=D0=B8=D0=BD=20=D0=9C?= =?UTF-8?q?=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=90=D0=BD=D0=B4=D1=80=D0=B5?= =?UTF-8?q?=D0=B5=D0=B2=D0=B8=D1=87?= Date: Thu, 20 Nov 2025 16:54:18 +0400 Subject: [PATCH] formatting --- lazy-lock.json | 1 + lsp/lua_ls.lua | 44 +++++++------- lsp/rust_analyzer.lua | 80 ++++++++++++-------------- lua/lazy_init.lua | 6 +- lua/lsp.lua | 46 +++++++-------- lua/plugins/autopairs.lua | 8 +-- lua/plugins/colorscheme.lua | 8 +-- lua/plugins/conform.lua | 19 ++++++ lua/plugins/fidget.lua | 2 +- lua/plugins/flash.lua | 45 +++++++++++++-- lua/plugins/gitsignes.lua | 8 +-- lua/plugins/illuminate.lua | 2 +- lua/plugins/lualine.lua | 10 ++-- lua/plugins/nvim-tree.lua | 6 +- lua/plugins/oil.lua | 7 ++- lua/plugins/rustaceanvim.lua | 7 ++- lua/plugins/telescope.lua | 18 +++--- lua/plugins/tiny-inline-diagnostic.lua | 18 +++--- lua/plugins/todo-comments.lua | 2 +- lua/plugins/treesitter.lua | 8 ++- lua/set.lua | 3 +- stylua.toml | 4 ++ 22 files changed, 205 insertions(+), 147 deletions(-) create mode 100644 lua/plugins/conform.lua create mode 100644 stylua.toml diff --git a/lazy-lock.json b/lazy-lock.json index cecc44e..7f88f73 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,5 +1,6 @@ { "alabaster.nvim": { "branch": "main", "commit": "59f1a91fd204d96d163932dcada8559fc6aee8cd" }, + "conform.nvim": { "branch": "master", "commit": "1bf8b5b9caee51507aa51eaed3da5b0f2595c6b9" }, "fidget.nvim": { "branch": "main", "commit": "e32b672d8fd343f9d6a76944fedb8c61d7d8111a" }, "flash.nvim": { "branch": "main", "commit": "fcea7ff883235d9024dc41e638f164a450c14ca2" }, "gitsigns.nvim": { "branch": "main", "commit": "1ee5c1fd068c81f9dd06483e639c2aa4587dc197" }, diff --git a/lsp/lua_ls.lua b/lsp/lua_ls.lua index d428f05..727a7a3 100644 --- a/lsp/lua_ls.lua +++ b/lsp/lua_ls.lua @@ -69,40 +69,40 @@ --- ---@type vim.lsp.Config -vim.lsp.config('lua_ls', { +vim.lsp.config("lua_ls", { on_init = function(client) if client.workspace_folders then local path = client.workspace_folders[1].name if - path ~= vim.fn.stdpath('config') - and (vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc')) + path ~= vim.fn.stdpath("config") + and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc")) then return end end - client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { runtime = { -- Tell the language server which version of Lua you're using (most -- likely LuaJIT in the case of Neovim) - version = 'LuaJIT', + version = "LuaJIT", -- Tell the language server how to find Lua modules same way as Neovim -- (see `:h lua-module-load`) path = { - 'lua/?.lua', - 'lua/?/init.lua', + "lua/?.lua", + "lua/?/init.lua", }, }, -- Make the server aware of Neovim runtime files workspace = { checkThirdParty = false, library = { - vim.env.VIMRUNTIME + vim.env.VIMRUNTIME, -- Depending on the usage, you might want to add additional paths -- here. -- '${3rd}/luv/library' -- '${3rd}/busted/library' - } + }, -- Or pull in all of 'runtimepath'. -- NOTE: this is a lot slower and will cause issues when working on -- your own configuration. @@ -110,25 +110,25 @@ vim.lsp.config('lua_ls', { -- library = { -- vim.api.nvim_get_runtime_file('', true), -- } - } + }, }) end, settings = { - Lua = {} - } + Lua = {}, + }, }) return { - cmd = { 'lua-language-server' }, - filetypes = { 'lua' }, + cmd = { "lua-language-server" }, + filetypes = { "lua" }, root_markers = { - '.luarc.json', - '.luarc.jsonc', - '.luacheckrc', - '.stylua.toml', - 'stylua.toml', - 'selene.toml', - 'selene.yml', - '.git', + ".luarc.json", + ".luarc.jsonc", + ".luacheckrc", + ".stylua.toml", + "stylua.toml", + "selene.toml", + "selene.yml", + ".git", }, } diff --git a/lsp/rust_analyzer.lua b/lsp/rust_analyzer.lua index 5993fe2..8b1e31e 100644 --- a/lsp/rust_analyzer.lua +++ b/lsp/rust_analyzer.lua @@ -22,31 +22,31 @@ --- https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26. local function reload_workspace(bufnr) - local clients = vim.lsp.get_clients { bufnr = bufnr, name = 'rust_analyzer' } + local clients = vim.lsp.get_clients({ bufnr = bufnr, name = "rust_analyzer" }) for _, client in ipairs(clients) do - vim.notify 'Reloading Cargo Workspace' + vim.notify("Reloading Cargo Workspace") ---@diagnostic disable-next-line:param-type-mismatch - client:request('rust-analyzer/reloadWorkspace', nil, function(err) + client:request("rust-analyzer/reloadWorkspace", nil, function(err) if err then error(tostring(err)) end - vim.notify 'Cargo workspace reloaded' + vim.notify("Cargo workspace reloaded") end, 0) end end local function is_library(fname) local user_home = vim.fs.normalize(vim.env.HOME) - local cargo_home = os.getenv 'CARGO_HOME' or user_home .. '/.cargo' - local registry = cargo_home .. '/registry/src' - local git_registry = cargo_home .. '/git/checkouts' + local cargo_home = os.getenv("CARGO_HOME") or user_home .. "/.cargo" + local registry = cargo_home .. "/registry/src" + local git_registry = cargo_home .. "/git/checkouts" - local rustup_home = os.getenv 'RUSTUP_HOME' or user_home .. '/.rustup' - local toolchains = rustup_home .. '/toolchains' + local rustup_home = os.getenv("RUSTUP_HOME") or user_home .. "/.rustup" + local toolchains = rustup_home .. "/toolchains" - for _, item in ipairs { toolchains, registry, git_registry } do + for _, item in ipairs({ toolchains, registry, git_registry }) do if vim.fs.relpath(item, fname) then - local clients = vim.lsp.get_clients { name = 'rust_analyzer' } + local clients = vim.lsp.get_clients({ name = "rust_analyzer" }) return #clients > 0 and clients[#clients].config.root_dir or nil end end @@ -54,8 +54,8 @@ end ---@type vim.lsp.Config return { - cmd = { 'rust-analyzer' }, - filetypes = { 'rust' }, + cmd = { "rust-analyzer" }, + filetypes = { "rust" }, root_dir = function(bufnr, on_dir) local fname = vim.api.nvim_buf_get_name(bufnr) local reused_dir = is_library(fname) @@ -64,40 +64,40 @@ return { return end - local cargo_crate_dir = vim.fs.root(fname, { 'Cargo.toml' }) + local cargo_crate_dir = vim.fs.root(fname, { "Cargo.toml" }) local cargo_workspace_root if cargo_crate_dir == nil then on_dir( - vim.fs.root(fname, { 'rust-project.json' }) - or vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) + vim.fs.root(fname, { "rust-project.json" }) + or vim.fs.dirname(vim.fs.find(".git", { path = fname, upward = true })[1]) ) return end local cmd = { - 'cargo', - 'metadata', - '--no-deps', - '--format-version', - '1', - '--manifest-path', - cargo_crate_dir .. '/Cargo.toml', + "cargo", + "metadata", + "--no-deps", + "--format-version", + "1", + "--manifest-path", + cargo_crate_dir .. "/Cargo.toml", } vim.system(cmd, { text = true }, function(output) if output.code == 0 then if output.stdout then local result = vim.json.decode(output.stdout) - if result['workspace_root'] then - cargo_workspace_root = vim.fs.normalize(result['workspace_root']) + if result["workspace_root"] then + cargo_workspace_root = vim.fs.normalize(result["workspace_root"]) end end on_dir(cargo_workspace_root or cargo_crate_dir) else vim.schedule(function() - vim.notify(('[rust_analyzer] cmd failed with code %d: %s\n%s'):format(output.code, cmd, output.stderr)) + vim.notify(("[rust_analyzer] cmd failed with code %d: %s\n%s"):format(output.code, cmd, output.stderr)) end) end end) @@ -107,24 +107,24 @@ return { serverStatusNotification = true, commands = { commands = { - 'rust-analyzer.showReferences', - 'rust-analyzer.runSingle', - 'rust-analyzer.debugSingle', + "rust-analyzer.showReferences", + "rust-analyzer.runSingle", + "rust-analyzer.debugSingle", }, }, }, }, before_init = function(init_params, config) -- See https://github.com/rust-lang/rust-analyzer/blob/eb5da56d839ae0a9e9f50774fa3eb78eb0964550/docs/dev/lsp-extensions.md?plain=1#L26 - if config.settings and config.settings['rust-analyzer'] then - init_params.initializationOptions = config.settings['rust-analyzer'] + if config.settings and config.settings["rust-analyzer"] then + init_params.initializationOptions = config.settings["rust-analyzer"] end ---@param command table{ title: string, command: string, arguments: any[] } - vim.lsp.commands['rust-analyzer.runSingle'] = function(command) + vim.lsp.commands["rust-analyzer.runSingle"] = function(command) local r = command.arguments[1] - local cmd = { 'cargo', unpack(r.args.cargoArgs) } + local cmd = { "cargo", unpack(r.args.cargoArgs) } if r.args.executableArgs and #r.args.executableArgs > 0 then - vim.list_extend(cmd, { '--', unpack(r.args.executableArgs) }) + vim.list_extend(cmd, { "--", unpack(r.args.executableArgs) }) end local proc = vim.system(cmd, { cwd = r.args.cwd }) @@ -139,16 +139,8 @@ return { end end, on_attach = function(_, bufnr) - vim.api.nvim_buf_create_user_command(bufnr, 'LspCargoReload', function() + vim.api.nvim_buf_create_user_command(bufnr, "LspCargoReload", function() reload_workspace(bufnr) - end, { desc = 'Reload current cargo workspace' }) - - -- Enable formatting on save - vim.api.nvim_create_autocmd("BufWritePre", { - buffer = bufnr, - callback = function() - vim.lsp.buf.format({ bufnr = bufnr }) - end - }) + end, { desc = "Reload current cargo workspace" }) end, } diff --git a/lua/lazy_init.lua b/lua/lazy_init.lua index 00e2d0f..1f28c33 100644 --- a/lua/lazy_init.lua +++ b/lua/lazy_init.lua @@ -10,8 +10,8 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then }) end vim.opt.rtp:prepend(lazypath) - + require("lazy").setup({ - spec = "plugins", - change_detection = { notify = false } + spec = "plugins", + change_detection = { notify = false }, }) diff --git a/lua/lsp.lua b/lua/lsp.lua index 90e2d65..159241b 100644 --- a/lua/lsp.lua +++ b/lua/lsp.lua @@ -1,36 +1,36 @@ vim.lsp.enable({ -- 'rust_analyzer', - 'lua_ls', + "lua_ls", }) -- Enable autocomplete -vim.api.nvim_create_autocmd('LspAttach', { +vim.api.nvim_create_autocmd("LspAttach", { callback = function(event) vim.lsp.completion.enable(true, event.data.client_id, event.buf, { autotrigger = true }) end, }) vim.diagnostic.config({ - underline = false, - signs = { - active = true, - text = { - [vim.diagnostic.severity.ERROR] = "", - [vim.diagnostic.severity.WARN] = "", - [vim.diagnostic.severity.HINT] = "󰟃", - [vim.diagnostic.severity.INFO] = "", - }, - }, - virtual_text = false, - float = { - border = "single", - format = function(diagnostic) - return string.format( - "%s (%s) [%s]", - diagnostic.message, - diagnostic.source, - diagnostic.code or diagnostic.user_data.lsp.code - ) - end, + underline = false, + signs = { + active = true, + text = { + [vim.diagnostic.severity.ERROR] = "", + [vim.diagnostic.severity.WARN] = "", + [vim.diagnostic.severity.HINT] = "󰟃", + [vim.diagnostic.severity.INFO] = "", }, + }, + virtual_text = false, + float = { + border = "single", + format = function(diagnostic) + return string.format( + "%s (%s) [%s]", + diagnostic.message, + diagnostic.source, + diagnostic.code or diagnostic.user_data.lsp.code + ) + end, + }, }) diff --git a/lua/plugins/autopairs.lua b/lua/plugins/autopairs.lua index 04448e7..4c70072 100644 --- a/lua/plugins/autopairs.lua +++ b/lua/plugins/autopairs.lua @@ -1,6 +1,6 @@ return { - 'windwp/nvim-autopairs', + "windwp/nvim-autopairs", config = function() - require('nvim-autopairs').setup() - end -} + require("nvim-autopairs").setup() + end, +} diff --git a/lua/plugins/colorscheme.lua b/lua/plugins/colorscheme.lua index dfa65e5..515c575 100644 --- a/lua/plugins/colorscheme.lua +++ b/lua/plugins/colorscheme.lua @@ -3,7 +3,7 @@ return { "p00f/alabaster.nvim", config = function() -- vim.cmd.colorscheme("alabaster") - end + end, }, { @@ -26,7 +26,7 @@ return { vim.cmd.colorscheme("gruber-darker") vim.api.nvim_set_hl(0, "Normal", { bg = "#101010" }) - vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#101010" }) - end - } + vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#101010" }) + end, + }, } diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua new file mode 100644 index 0000000..78ae549 --- /dev/null +++ b/lua/plugins/conform.lua @@ -0,0 +1,19 @@ +return { + "stevearc/conform.nvim", + config = function() + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + rust = { "rustfmt", lsp_format = "fallback" }, + }, + }) + + -- Enable formatting on save + vim.api.nvim_create_autocmd("BufWritePre", { + pattern = "*", + callback = function(args) + require("conform").format({ bufnr = args.buf }) + end, + }) + end, +} diff --git a/lua/plugins/fidget.lua b/lua/plugins/fidget.lua index 5cbecd0..2452b87 100644 --- a/lua/plugins/fidget.lua +++ b/lua/plugins/fidget.lua @@ -2,5 +2,5 @@ return { "j-hui/fidget.nvim", config = function() require("fidget").setup() - end + end, } diff --git a/lua/plugins/flash.lua b/lua/plugins/flash.lua index 7862ff2..dc4b188 100644 --- a/lua/plugins/flash.lua +++ b/lua/plugins/flash.lua @@ -4,10 +4,45 @@ return { ---@type Flash.Config opts = {}, keys = { - { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, - { "S", mode = { "n", "x", "o" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, - { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, - { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, - { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, + { + "s", + mode = { "n", "x", "o" }, + function() + require("flash").jump() + end, + desc = "Flash", + }, + { + "S", + mode = { "n", "x", "o" }, + function() + require("flash").treesitter() + end, + desc = "Flash Treesitter", + }, + { + "r", + mode = "o", + function() + require("flash").remote() + end, + desc = "Remote Flash", + }, + { + "R", + mode = { "o", "x" }, + function() + require("flash").treesitter_search() + end, + desc = "Treesitter Search", + }, + { + "", + mode = { "c" }, + function() + require("flash").toggle() + end, + desc = "Toggle Flash Search", + }, }, } diff --git a/lua/plugins/gitsignes.lua b/lua/plugins/gitsignes.lua index e6ed33f..310605a 100644 --- a/lua/plugins/gitsignes.lua +++ b/lua/plugins/gitsignes.lua @@ -1,8 +1,8 @@ return { "lewis6991/gitsigns.nvim", config = function() - require('gitsigns').setup() - vim.keymap.set('n', 'gb', ':Gitsigns blame', {}) - vim.keymap.set('n', 'gs', ':Gitsigns preview_hunk', {}) - end + require("gitsigns").setup() + vim.keymap.set("n", "gb", ":Gitsigns blame", {}) + vim.keymap.set("n", "gs", ":Gitsigns preview_hunk", {}) + end, } diff --git a/lua/plugins/illuminate.lua b/lua/plugins/illuminate.lua index 020c98c..de4c1de 100644 --- a/lua/plugins/illuminate.lua +++ b/lua/plugins/illuminate.lua @@ -1,3 +1,3 @@ return { - "RRethy/vim-illuminate" + "RRethy/vim-illuminate", } diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index e47c506..ddba7ec 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,7 +1,7 @@ return { - 'nvim-lualine/lualine.nvim', - dependencies = { 'nvim-tree/nvim-web-devicons' }, + "nvim-lualine/lualine.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, config = function() - require('lualine').setup() - end -} + require("lualine").setup() + end, +} diff --git a/lua/plugins/nvim-tree.lua b/lua/plugins/nvim-tree.lua index 8a5b09c..d1ca258 100644 --- a/lua/plugins/nvim-tree.lua +++ b/lua/plugins/nvim-tree.lua @@ -4,7 +4,9 @@ return { "nvim-tree/nvim-web-devicons", -- optional, for file icons }, config = function() - require("nvim-tree").setup() - vim.keymap.set('n', 'e', ':NvimTreeFindFileToggle', {}) + require("nvim-tree").setup({ + view = { adaptive_size = true }, + }) + vim.keymap.set("n", "e", ":NvimTreeFindFileToggle", {}) end, } diff --git a/lua/plugins/oil.lua b/lua/plugins/oil.lua index 979bfbc..8f500e6 100644 --- a/lua/plugins/oil.lua +++ b/lua/plugins/oil.lua @@ -1,11 +1,14 @@ return { - 'stevearc/oil.nvim', + "stevearc/oil.nvim", dependencies = { "nvim-tree/nvim-web-devicons" }, lazy = false, config = function() require("oil").setup({ default_file_explorer = true, + view_options = { + show_hidden = true, + }, }) vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) - end + end, } diff --git a/lua/plugins/rustaceanvim.lua b/lua/plugins/rustaceanvim.lua index c38e960..1b82658 100644 --- a/lua/plugins/rustaceanvim.lua +++ b/lua/plugins/rustaceanvim.lua @@ -1,4 +1,5 @@ return { - 'mrcjkb/rustaceanvim', - version = '^6', - lazy = false,} + "mrcjkb/rustaceanvim", + version = "^6", + lazy = false, +} diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index 2890a15..d40c7ab 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1,12 +1,12 @@ return { - 'nvim-telescope/telescope.nvim', - tag = '0.1.9', - dependencies = { 'nvim-lua/plenary.nvim' }, + "nvim-telescope/telescope.nvim", + tag = "0.1.9", + dependencies = { "nvim-lua/plenary.nvim" }, config = function() - local builtin = require('telescope.builtin') - vim.keymap.set('n', 'ff', builtin.find_files, {}) - vim.keymap.set('n', 'fg', builtin.live_grep, {}) - vim.keymap.set('n', 'fb', builtin.buffers, {}) - vim.keymap.set('n', 'fh', builtin.help_tags, {}) - end + local builtin = require("telescope.builtin") + vim.keymap.set("n", "ff", builtin.find_files, {}) + vim.keymap.set("n", "fg", builtin.live_grep, {}) + vim.keymap.set("n", "fb", builtin.buffers, {}) + vim.keymap.set("n", "fh", builtin.help_tags, {}) + end, } diff --git a/lua/plugins/tiny-inline-diagnostic.lua b/lua/plugins/tiny-inline-diagnostic.lua index e879b2b..5d82844 100644 --- a/lua/plugins/tiny-inline-diagnostic.lua +++ b/lua/plugins/tiny-inline-diagnostic.lua @@ -1,11 +1,11 @@ return { - "rachartier/tiny-inline-diagnostic.nvim", - event = "VeryLazy", - priority = 1000, - config = function() - require("tiny-inline-diagnostic").setup() - vim.diagnostic.config({ - virtual_text = false, - }) - end, + "rachartier/tiny-inline-diagnostic.nvim", + event = "VeryLazy", + priority = 1000, + config = function() + require("tiny-inline-diagnostic").setup() + vim.diagnostic.config({ + virtual_text = false, + }) + end, } diff --git a/lua/plugins/todo-comments.lua b/lua/plugins/todo-comments.lua index 2441663..c88cb75 100644 --- a/lua/plugins/todo-comments.lua +++ b/lua/plugins/todo-comments.lua @@ -1,5 +1,5 @@ return { "folke/todo-comments.nvim", dependencies = { "nvim-lua/plenary.nvim" }, - opts = {} + opts = {}, } diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index e7cfb29..64e8fa0 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -3,15 +3,17 @@ return { build = ":TSUpdate", config = function() local configs = require("nvim-treesitter.configs") - + configs.setup({ ensure_installed = { - "lua", "vim", "vimdoc" + "lua", + "vim", + "vimdoc", }, auto_install = true, sync_install = false, highlight = { enable = true }, indent = { enable = true }, }) - end + end, } diff --git a/lua/set.lua b/lua/set.lua index f4ee9ec..c7e5f0d 100644 --- a/lua/set.lua +++ b/lua/set.lua @@ -28,5 +28,4 @@ vim.opt.isfname:append("@-@") vim.opt.updatetime = 50 -vim.opt.colorcolumn = {"80", "100", "120"} - +vim.opt.colorcolumn = { "80", "100", "120" } diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..4524aeb --- /dev/null +++ b/stylua.toml @@ -0,0 +1,4 @@ +indent_type = "Spaces" +indent_width = 2 +column_width = 120 + -- knotmirror 0.0.1