From 1bc4074843eeba4b30d6ee2ed877afd74e1fc44e Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Fri, 1 Mar 2024 19:11:19 +0530 Subject: fmt: init stylua --- init.lua | 6 +- lua/core/init.lua | 4 +- lua/core/maps.lua | 5 +- lua/pacman.lua | 8 +-- lua/plugins/init.lua | 31 ++++---- lua/plugins/maps.lua | 46 ++++++------ lua/plugins/opts/cmp.lua | 160 ++++++++++++++++++++--------------------- lua/plugins/opts/lspconfig.lua | 48 ++++++------- lua/plugins/opts/lualine.lua | 2 +- lua/plugins/opts/misc.lua | 40 +++++------ 10 files changed, 174 insertions(+), 176 deletions(-) diff --git a/init.lua b/init.lua index 60559b0..1cf90ea 100644 --- a/init.lua +++ b/init.lua @@ -1,3 +1,3 @@ -require "core" -require "pacman" -require "plugins" +require("core") +require("pacman") +require("plugins") diff --git a/lua/core/init.lua b/lua/core/init.lua index c296ffb..ff20ffb 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,2 +1,2 @@ -require "core.opts" -require "core.maps" +require("core.opts") +require("core.maps") diff --git a/lua/core/maps.lua b/lua/core/maps.lua index 31f899c..14f05f1 100644 --- a/lua/core/maps.lua +++ b/lua/core/maps.lua @@ -9,14 +9,14 @@ local maps = { vim.api.nvim_set_option_value("colorcolumn", "", {}) end end, - "Toggle 80 column hint" + "Toggle 80 column hint", }, }, t = { [""] = { vim.api.nvim_replace_termcodes("", true, true, true), - "Escape terminal mode" + "Escape terminal mode", }, }, @@ -26,7 +26,6 @@ local maps = { }, } - for mode, keytab in pairs(maps) do for key, fun in pairs(keytab) do vim.keymap.set(mode, key, fun[1], { desc = fun[2] }) diff --git a/lua/pacman.lua b/lua/pacman.lua index ec4b7f0..cdc0947 100644 --- a/lua/pacman.lua +++ b/lua/pacman.lua @@ -1,8 +1,8 @@ -local path = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +local path = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local repo = "https://github.com/folke/lazy.nvim.git" local lazy_dl = function() - vim.print " 󰦗 downloading lazy.nvim" + vim.print(" 󰦗 downloading lazy.nvim") vim.fn.system({ "git", @@ -13,8 +13,8 @@ local lazy_dl = function() path, }) - vim.print "" - vim.cmd "redraw" + vim.print("") + vim.cmd("redraw") end if not vim.loop.fs_stat(path) then diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 07d7639..3a2fc26 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -11,7 +11,7 @@ require("lazy").setup({ { "nvim-lualine/lualine.nvim", - opts = require "plugins.opts.lualine", + opts = require("plugins.opts.lualine"), }, { @@ -19,10 +19,10 @@ require("lazy").setup({ lazy = false, priority = 1000, - opts = { transparent = true, }, + opts = { transparent = true }, config = function(_, opts) require("tokyonight").setup(opts) - vim.cmd.colorscheme "tokyonight-night" + vim.cmd.colorscheme("tokyonight-night") end, }, @@ -32,15 +32,15 @@ require("lazy").setup({ event = { "BufReadPost", "BufNewFile" }, cmd = { "TSInstall", "TSBufEnable", "TSBufDisable", "TSModuleInfo" }, - opts = require "plugins.opts.treesitter", + opts = require("plugins.opts.treesitter"), config = function(_, opts) require("nvim-treesitter.configs").setup(opts) end, }, { - 'VonHeikemen/lsp-zero.nvim', - branch = 'v3.x', + "VonHeikemen/lsp-zero.nvim", + branch = "v3.x", lazy = true, config = false, @@ -52,11 +52,11 @@ require("lazy").setup({ }, { - 'hrsh7th/nvim-cmp', - event = 'InsertEnter', + "hrsh7th/nvim-cmp", + event = "InsertEnter", dependencies = { { - 'L3MON4D3/LuaSnip', + "L3MON4D3/LuaSnip", dependencies = "rafamadriz/friendly-snippets", config = function(_, opts) @@ -74,7 +74,7 @@ require("lazy").setup({ require("nvim-autopairs").setup(opts) -- setup cmp for autopairs - local cmp_autopairs = require "nvim-autopairs.completion.cmp" + local cmp_autopairs = require("nvim-autopairs.completion.cmp") require("cmp").event:on("confirm_done", cmp_autopairs.on_confirm_done()) end, }, @@ -89,18 +89,17 @@ require("lazy").setup({ }, opts = function() - return require "plugins.opts.cmp" + return require("plugins.opts.cmp") end, - }, { - 'neovim/nvim-lspconfig', - cmd = 'LspInfo', - event = { 'BufReadPre', 'BufNewFile' }, + "neovim/nvim-lspconfig", + cmd = "LspInfo", + event = { "BufReadPre", "BufNewFile" }, config = function() - require "plugins.opts.lspconfig" + require("plugins.opts.lspconfig") end, }, }) diff --git a/lua/plugins/maps.lua b/lua/plugins/maps.lua index 7c5f29b..84a0703 100644 --- a/lua/plugins/maps.lua +++ b/lua/plugins/maps.lua @@ -2,34 +2,34 @@ local M = {} local maps = {} maps.gitsigns = { - n = { - ["gb"] = { - function() - package.loaded.gitsigns.blame_line() - end, - "Blame line", - }, + n = { + ["gb"] = { + function() + package.loaded.gitsigns.blame_line() + end, + "Blame line", + }, - ["td"] = { - function() - require("gitsigns").toggle_deleted() - end, - "Toggle deleted", - }, - }, + ["td"] = { + function() + require("gitsigns").toggle_deleted() + end, + "Toggle deleted", + }, + }, } M.load = function(name, opts) - local submaps = maps[name] - opts = opts or {} + local submaps = maps[name] + opts = opts or {} - vim.schedule(function() - for mode, keytab in pairs(submaps) do - for key, fun in pairs(keytab) do - vim.keymap.set(mode, key, fun[1], { desc = fun[2] }, opts) - end - end - end) + vim.schedule(function() + for mode, keytab in pairs(submaps) do + for key, fun in pairs(keytab) do + vim.keymap.set(mode, key, fun[1], { desc = fun[2] }, opts) + end + end + end) end return M diff --git a/lua/plugins/opts/cmp.lua b/lua/plugins/opts/cmp.lua index c423a31..65e48b5 100644 --- a/lua/plugins/opts/cmp.lua +++ b/lua/plugins/opts/cmp.lua @@ -1,96 +1,96 @@ -local cmp = require "cmp" -local lspzero_cmp_act = require('lsp-zero').cmp_action() +local cmp = require("cmp") +local lspzero_cmp_act = require("lsp-zero").cmp_action() local function border(hl_name) - return { - { "╭", hl_name }, - { "─", hl_name }, - { "╮", hl_name }, - { "│", hl_name }, - { "╯", hl_name }, - { "─", hl_name }, - { "╰", hl_name }, - { "│", hl_name }, - } + return { + { "╭", hl_name }, + { "─", hl_name }, + { "╮", hl_name }, + { "│", hl_name }, + { "╯", hl_name }, + { "─", hl_name }, + { "╰", hl_name }, + { "│", hl_name }, + } end local options = { - completion = { - completeopt = "menu,menuone", - }, + completion = { + completeopt = "menu,menuone", + }, - window = { - completion = { - border = border "CmpBorder", - winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,CursorLine:PmenuSel", - scrollbar = false, - }, - documentation = { - border = border "CmpDocBorder", - winhighlight = "Normal:CmpDoc", - }, - }, + window = { + completion = { + border = border("CmpBorder"), + winhighlight = "Normal:CmpPmenu,CursorLine:CmpSel,CursorLine:PmenuSel", + scrollbar = false, + }, + documentation = { + border = border("CmpDocBorder"), + winhighlight = "Normal:CmpDoc", + }, + }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, + snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, - formatting = { - fields = { "abbr", "kind", "menu" }, + formatting = { + fields = { "abbr", "kind", "menu" }, - format = function(_, item) - local icons = { - Text = " ", - Method = " ", - Function = " ", - Constructor = " ", - Field = " ", - Variable = " ", - Class = " ", - Interface = " ", - Module = " ", - Property = " ", - Unit = " ", - Value = " ", - Enum = " ", - Keyword = " ", - Snippet = " ", - Color = " ", - File = " ", - Reference = " ", - Folder = " ", - EnumMember = " ", - Constant = " ", - Struct = " ", - Event = " ", - Operator = " ", - TypeParameter = " ", - } + format = function(_, item) + local icons = { + Text = " ", + Method = " ", + Function = " ", + Constructor = " ", + Field = " ", + Variable = " ", + Class = " ", + Interface = " ", + Module = " ", + Property = " ", + Unit = " ", + Value = " ", + Enum = " ", + Keyword = " ", + Snippet = " ", + Color = " ", + File = " ", + Reference = " ", + Folder = " ", + EnumMember = " ", + Constant = " ", + Struct = " ", + Event = " ", + Operator = " ", + TypeParameter = " ", + } - local icon = icons[item.kind] or "" - item.kind = string.format(" %s %s", icon, item.kind) + local icon = icons[item.kind] or "" + item.kind = string.format(" %s %s", icon, item.kind) - return item - end, - }, + return item + end, + }, - mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = lspzero_cmp_act.luasnip_jump_forward(), - [''] = lspzero_cmp_act.luasnip_jump_backward(), - }), + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = lspzero_cmp_act.luasnip_jump_forward(), + [""] = lspzero_cmp_act.luasnip_jump_backward(), + }), - sources = { - { name = "nvim_lsp" }, - { name = "luasnip" }, - { name = "buffer" }, - { name = "nvim_lua" }, - { name = "path" }, - }, + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "buffer" }, + { name = "nvim_lua" }, + { name = "path" }, + }, } return options diff --git a/lua/plugins/opts/lspconfig.lua b/lua/plugins/opts/lspconfig.lua index 798e6c8..0a00fa7 100644 --- a/lua/plugins/opts/lspconfig.lua +++ b/lua/plugins/opts/lspconfig.lua @@ -1,35 +1,35 @@ -local lspconfig = require "lspconfig" -local lsp_zero = require "lsp-zero" +local lspconfig = require("lspconfig") +local lsp_zero = require("lsp-zero") lsp_zero.extend_lspconfig() lsp_zero.set_sign_icons({ - error = "󰅚 ", - warn = "󰀪 ", - info = "󰋽 ", - hint = "󰌶 " + error = "󰅚 ", + warn = "󰀪 ", + info = "󰋽 ", + hint = "󰌶 ", }) lsp_zero.on_attach(function(_, bufnr) - lsp_zero.default_keymaps({buffer = bufnr}) + lsp_zero.default_keymaps({ buffer = bufnr }) end) lspconfig.lua_ls.setup(lsp_zero.nvim_lua_ls({ - settings = { - Lua = { - diagnostics = { - globals = { 'mp' } -- mpv global - } - } - } + settings = { + Lua = { + diagnostics = { + globals = { "mp" }, -- mpv global + }, + }, + }, })) -lspconfig.ccls.setup { - init_options = { - cache = { - directory = vim.fn.stdpath('cache') .. '/ccls' - } - } -} +lspconfig.ccls.setup({ + init_options = { + cache = { + directory = vim.fn.stdpath("cache") .. "/ccls", + }, + }, +}) -lspconfig.bashls.setup {} -lspconfig.nil_ls.setup {} -lspconfig.pyright.setup {} +lspconfig.bashls.setup({}) +lspconfig.nil_ls.setup({}) +lspconfig.pyright.setup({}) diff --git a/lua/plugins/opts/lualine.lua b/lua/plugins/opts/lualine.lua index 456fa37..708a12b 100644 --- a/lua/plugins/opts/lualine.lua +++ b/lua/plugins/opts/lualine.lua @@ -2,7 +2,7 @@ return { sections = { lualine_a = { "mode" }, lualine_b = { "branch", "diff" }, - lualine_c = {{ "buffers", mode = 2 }}, + lualine_c = { { "buffers", mode = 2 } }, lualine_x = { "diagnostics" }, lualine_y = { "progress" }, diff --git a/lua/plugins/opts/misc.lua b/lua/plugins/opts/misc.lua index e228023..a7cbafa 100644 --- a/lua/plugins/opts/misc.lua +++ b/lua/plugins/opts/misc.lua @@ -1,30 +1,30 @@ local M = {} -local maps = require "plugins.maps" +local maps = require("plugins.maps") M.gitsigns = { - signs = { - add = { text = "+" }, - change = { text = "~" }, - delete = { text = "-" }, - topdelete = { text = "‾" }, - changedelete = { text = "~" }, - untracked = { text = "│" }, - }, + signs = { + add = { text = "+" }, + change = { text = "~" }, + delete = { text = "-" }, + topdelete = { text = "‾" }, + changedelete = { text = "~" }, + untracked = { text = "│" }, + }, - on_attach = function(bufnr) - maps.load("gitsigns", { buffer = bufnr }) - end, + on_attach = function(bufnr) + maps.load("gitsigns", { buffer = bufnr }) + end, } -M.luasnip = function (opts) - require("luasnip").config.set_config(opts) +M.luasnip = function(opts) + require("luasnip").config.set_config(opts) - -- vscode format - require("luasnip.loaders.from_vscode").lazy_load() - -- snipmate format - require("luasnip.loaders.from_snipmate").lazy_load() - -- lua format - require("luasnip.loaders.from_lua").lazy_load() + -- vscode format + require("luasnip.loaders.from_vscode").lazy_load() + -- snipmate format + require("luasnip.loaders.from_snipmate").lazy_load() + -- lua format + require("luasnip.loaders.from_lua").lazy_load() end return M -- cgit v1.2.3