From b9b77abfa420683e6debcf3b80fd300636a6377c Mon Sep 17 00:00:00 2001 From: ShatteredMINT Date: Mon, 30 Sep 2024 06:12:57 +0200 Subject: [PATCH] autoformat --- lua/config/lazy.lua | 54 ++++++++++++++++++------------------- lua/config/lsp.lua | 16 ++++++++--- lua/config/nvim-cmp.lua | 58 ++++++++++++++++++++-------------------- lua/config/nvim-tree.lua | 30 ++++++++++----------- lua/config/theme.lua | 2 +- lua/plugins/lazy.lua | 17 ++++++------ plugin/keymap.lua | 12 ++++----- plugin/options.lua | 36 ++++++++++++------------- 8 files changed, 116 insertions(+), 109 deletions(-) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 68180c7..6d47715 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -2,41 +2,41 @@ require("lazy").setup({ "navarasu/onedark.nvim", -- Auto-completion engine - { - "hrsh7th/nvim-cmp", - dependencies = { - "hrsh7th/cmp-nvim-lsp", -- lsp auto-completion - "hrsh7th/cmp-buffer", -- buffer auto-completion - "hrsh7th/cmp-path", -- path auto-completion - "hrsh7th/cmp-cmdline", -- cmdline auto-completion - }, - config = function() - require("config.nvim-cmp") - end, - }, - -- Code snippet engine - { - "L3MON4D3/LuaSnip", - version = "v2.*", - }, + { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", -- lsp auto-completion + "hrsh7th/cmp-buffer", -- buffer auto-completion + "hrsh7th/cmp-path", -- path auto-completion + "hrsh7th/cmp-cmdline", -- cmdline auto-completion + }, + config = function() + require("config.nvim-cmp") + end, + }, + -- Code snippet engine + { + "L3MON4D3/LuaSnip", + version = "v2.*", + }, -- LSP manager - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", -- file explorer on the side "nvim-tree/nvim-tree.lua", -- lazygit integration - { - "kdheepak/lazygit.nvim", - lazy = false, - -- optional for floating window border decoration - dependencies = { - "nvim-lua/plenary.nvim", + { + "kdheepak/lazygit.nvim", + lazy = false, + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, }, - }, }) diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index db15a76..2855d6d 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -8,13 +8,21 @@ require('mason').setup({ } }) -local servers = { 'pylsp', 'lua_ls', 'rust_analyzer', 'zls'} +local servers = { 'pylsp', 'lua_ls', 'rust_analyzer', 'zls' } require('mason-lspconfig').setup({ -- A list of servers to automatically install if they're not already installed ensure_installed = servers, }) +-- auto format on save +vim.api.nvim_create_autocmd("BufWritePre", { + buffer = vim.b.buffer, + callback = function() + vim.lsp.buf.format { async = false } + end +}) + -- Set different settings for different languages' LSP -- LSP list: https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md -- How to use setup({}): https://github.com/neovim/nvim-lspconfig/wiki/Understanding-setup-%7B%7D @@ -63,7 +71,7 @@ end -- 2. add configuration below for _, lsp in ipairs(servers) do - lspconfig[lsp].setup { - on_attach = on_attach, - } + lspconfig[lsp].setup { + on_attach = on_attach, + } end diff --git a/lua/config/nvim-cmp.lua b/lua/config/nvim-cmp.lua index 6dfec5a..86c331c 100644 --- a/lua/config/nvim-cmp.lua +++ b/lua/config/nvim-cmp.lua @@ -16,7 +16,7 @@ cmp.setup({ }, mapping = cmp.mapping.preset.insert({ -- Use to scroll the docs - ['K'] = cmp.mapping.scroll_docs( -4), + ['K'] = cmp.mapping.scroll_docs(-4), ['J'] = cmp.mapping.scroll_docs(4), -- Use to switch in items ['k'] = cmp.mapping.select_prev_item(), @@ -40,40 +40,40 @@ cmp.setup({ [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() - elseif luasnip.jumpable( -1) then - luasnip.jump( -1) + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) else fallback() end end, { "i", "s" }), }), - -- Let's configure the item's appearance - -- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance - formatting = { - -- Set order from left to right - -- kind: single letter indicating the type of completion - -- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word" - -- menu: extra text for the popup menu, displayed after "word" or "abbr" - fields = { 'abbr', 'menu' }, + -- Let's configure the item's appearance + -- source: https://github.com/hrsh7th/nvim-cmp/wiki/Menu-Appearance + formatting = { + -- Set order from left to right + -- kind: single letter indicating the type of completion + -- abbr: abbreviation of "word"; when not empty it is used in the menu instead of "word" + -- menu: extra text for the popup menu, displayed after "word" or "abbr" + fields = { 'abbr', 'menu' }, - -- customize the appearance of the completion menu - format = function(entry, vim_item) - vim_item.menu = ({ - nvim_lsp = '[Lsp]', - luasnip = '[Luasnip]', - buffer = '[File]', - path = '[Path]', - })[entry.source.name] - return vim_item - end, - }, + -- customize the appearance of the completion menu + format = function(entry, vim_item) + vim_item.menu = ({ + nvim_lsp = '[Lsp]', + luasnip = '[Luasnip]', + buffer = '[File]', + path = '[Path]', + })[entry.source.name] + return vim_item + end, + }, - -- Set source precedence - sources = cmp.config.sources({ - { name = 'nvim_lsp' }, -- For nvim-lsp - { name = 'luasnip' }, -- For luasnip user - { name = 'buffer' }, -- For buffer word completion - { name = 'path' }, -- For path completion - }) + -- Set source precedence + sources = cmp.config.sources({ + { name = 'nvim_lsp' }, -- For nvim-lsp + { name = 'luasnip' }, -- For luasnip user + { name = 'buffer' }, -- For buffer word completion + { name = 'path' }, -- For path completion + }) }) diff --git a/lua/config/nvim-tree.lua b/lua/config/nvim-tree.lua index fd611dd..15f8c86 100644 --- a/lua/config/nvim-tree.lua +++ b/lua/config/nvim-tree.lua @@ -1,25 +1,25 @@ require("nvim-tree").setup({ - git = { + git = { enable = true, - }, - renderer = { + }, + renderer = { highlight_git = true, icons = { - show = { - git = true, - }, - glyphs = { - folder = { - default = "", + show = { + git = true, + }, + glyphs = { + folder = { + default = "", + }, }, - }, }, - }, - }) + }, +}) local opts = { - noremap = true, -- non-recursive - silent = true, -- do not show message + noremap = true, -- non-recursive + silent = true, -- do not show message } -vim.keymap.set('n', "e", function () require("nvim-tree.api").tree.toggle() end, opts) +vim.keymap.set('n', "e", function() require("nvim-tree.api").tree.toggle() end, opts) diff --git a/lua/config/theme.lua b/lua/config/theme.lua index f4b89ac..2491d46 100644 --- a/lua/config/theme.lua +++ b/lua/config/theme.lua @@ -1,6 +1,6 @@ local onedark = require("onedark") -onedark.setup{ +onedark.setup { style = "darker" } onedark.load() diff --git a/lua/plugins/lazy.lua b/lua/plugins/lazy.lua index 14d91f8..840b29a 100644 --- a/lua/plugins/lazy.lua +++ b/lua/plugins/lazy.lua @@ -1,13 +1,12 @@ 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, - }) + 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) - diff --git a/plugin/keymap.lua b/plugin/keymap.lua index edd76e2..ba8f1b4 100644 --- a/plugin/keymap.lua +++ b/plugin/keymap.lua @@ -1,7 +1,7 @@ -- define common options local opts = { - noremap = true, -- non-recursive - silent = true, -- do not show message + noremap = true, -- non-recursive + silent = true, -- do not show message } local map = vim.keymap.set @@ -18,10 +18,10 @@ map('n', 'wk', 'k', opts) map('n', 'wl', 'l', opts) local step_size = 4 -map('n', 'wJ', ':resize -'.. step_size ..'', opts) -map('n', 'wK', ':resize +'.. step_size ..'', opts) -map('n', 'wH', ':vertical resize -'.. step_size ..'', opts) -map('n', 'wL', ':vertical resize +'.. step_size ..'', opts) +map('n', 'wJ', ':resize -' .. step_size .. '', opts) +map('n', 'wK', ':resize +' .. step_size .. '', opts) +map('n', 'wH', ':vertical resize -' .. step_size .. '', opts) +map('n', 'wL', ':vertical resize +' .. step_size .. '', opts) map('n', 'wn', ':windo new', opts) map('n', 'wc', ':close', opts) diff --git a/plugin/options.lua b/plugin/options.lua index 36246ba..9edf7a9 100644 --- a/plugin/options.lua +++ b/plugin/options.lua @@ -1,26 +1,26 @@ -- Hint: use `:h