From 97f44a1340ed833b277406571b4e7e97331eb2ac Mon Sep 17 00:00:00 2001 From: sgoudham Date: Fri, 16 Dec 2022 02:10:07 +0000 Subject: [PATCH] feat(lvim): add lua-format --- dot_config/lvim/config.lua | 123 ++++++++++++++++++------------------- 1 file changed, 60 insertions(+), 63 deletions(-) diff --git a/dot_config/lvim/config.lua b/dot_config/lvim/config.lua index 2345d83..a6c8429 100644 --- a/dot_config/lvim/config.lua +++ b/dot_config/lvim/config.lua @@ -34,25 +34,38 @@ local mappings = { [''] = cmp.mapping.scroll_docs(4), } lvim.builtin.cmp.cmdline.enable = true -lvim.builtin.cmp.mapping = vim.tbl_deep_extend("keep", mappings, lvim.builtin.cmp.mapping) +lvim.builtin.cmp.mapping = vim.tbl_deep_extend("keep", mappings, + lvim.builtin.cmp.mapping) -- lsp local lsp_diagnostics = { update_in_insert = true, - float = { - border = "rounded" - } + float = { border = "rounded" }, } local buffer_mappings = { normal_mode = { - ["ge"] = { function() require("telescope.builtin").diagnostics() end, "Display Workplace Diagnostics" }, - ["gr"] = { function() require("telescope.builtin").lsp_references() end, "Goto References" }, - ["gd"] = { function() require("telescope.builtin").lsp_definitions() end, "Goto Definitions" }, - ["gI"] = { function() require("telescope.builtin").lsp_implementations() end, "Goto Implementations" } - } + ["ge"] = { + function() require("telescope.builtin").diagnostics() end, + "Display Workplace Diagnostics", + }, + ["gr"] = { + function() require("telescope.builtin").lsp_references() end, + "Goto References", + }, + ["gd"] = { + function() require("telescope.builtin").lsp_definitions() end, + "Goto Definitions", + }, + ["gI"] = { + function() require("telescope.builtin").lsp_implementations() end, + "Goto Implementations", + }, + }, } -lvim.lsp.diagnostics = vim.tbl_deep_extend("keep", lsp_diagnostics, lvim.lsp.diagnostics) -lvim.lsp.buffer_mappings = vim.tbl_deep_extend("keep", buffer_mappings, lvim.lsp.buffer_mappings) +lvim.lsp.diagnostics = vim.tbl_deep_extend("keep", lsp_diagnostics, + lvim.lsp.diagnostics) +lvim.lsp.buffer_mappings = vim.tbl_deep_extend("keep", buffer_mappings, + lvim.lsp.buffer_mappings) -- useful lvim.keys.normal_mode[""] = "zz" @@ -75,7 +88,10 @@ lvim.builtin.which_key.mappings["f"] = { g = { "Telescope live_grep", "Find Text" }, R = { "Telescope registers", "Find Registers" }, k = { "Telescope keymaps", "Find Keymaps" }, - c = { "Telescope current_buffer_fuzzy_find", "Find Text In Current Buffer" }, + c = { + "Telescope current_buffer_fuzzy_find", + "Find Text In Current Buffer", + }, C = { "Telescope commands", "Find Commands" }, r = { "Telescope oldfiles", "Open Recent File" }, p = { "Telescope projects", "Open Projects" }, @@ -85,9 +101,7 @@ lvim.builtin.which_key.mappings["f"] = { local _, actions = pcall(require, "telescope.actions") lvim.builtin.telescope.defaults.prompt_prefix = "🔍 " lvim.builtin.telescope.defaults.selection_caret = "> " -lvim.builtin.telescope.defaults.file_ignore_patterns = { - ".git/" -} +lvim.builtin.telescope.defaults.file_ignore_patterns = { ".git/" } lvim.builtin.telescope.defaults.mappings = { i = { [""] = actions.move_selection_next, @@ -99,7 +113,7 @@ lvim.builtin.telescope.defaults.mappings = { [""] = actions.move_selection_next, [""] = actions.move_selection_previous, [""] = actions.preview_scrolling_down, - [""] = actions.preview_scrolling_up + [""] = actions.preview_scrolling_up, }, } @@ -144,19 +158,14 @@ lvim.builtin.treesitter.ensure_installed = { "html", "go", "erlang", - "toml" + "toml", } -require("lspconfig.ui.windows").default_options.border = "rounded" - ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "hls" }) -local opts = { - cmd = { - "haskell-language-server-9.2.4", "--lsp" - } -} -- check the lspconfig documentation for a list of all possible options +local opts = { cmd = { "haskell-language-server-9.2.4", "--lsp" } } -- check the lspconfig documentation for a list of all possible options require("lvim.lsp.manager").setup("hls", opts) +require("lspconfig.ui.windows").default_options.border = "rounded" -- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` @@ -175,21 +184,21 @@ require("lvim.lsp.manager").setup("hls", opts) -- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") -- end --- -- set a formatter, this will override the language server formatting capabilities (if it exists) --- local formatters = require "lvim.lsp.null-ls.formatters" --- formatters.setup { --- { command = "black", filetypes = { "python" } }, --- { command = "isort", filetypes = { "python" } }, --- { --- -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration --- command = "prettier", --- ---@usage arguments to pass to the formatter --- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` --- extra_args = { "--print-with", "100" }, --- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. --- filetypes = { "typescript", "typescriptreact" }, --- }, --- } +local formatters = require "lvim.lsp.null-ls.formatters" +formatters.setup { + { + command = "lua-format", + filetypes = { "lua" }, + extra_args = { + "--spaces-inside-table-braces", + "--indent-width=2", + "--tab-width=2", + "--continuation-indent-width=2", + "--chop-down-table", + "--extra-sep-at-table-end", + }, + }, +} -- -- set additional linters -- local linters = require "lvim.lsp.null-ls.linters" @@ -225,31 +234,26 @@ lvim.plugins = { { name = "chezmoi", command = [[chezmoi managed -x encrypted -i files | awk '{ printf("%s/%s\n", "~", $0) }']], - opts = require('telescope.themes').get_dropdown({}) + opts = require('telescope.themes').get_dropdown({}), }, }, } - end + end, }, { 'stevearc/dressing.nvim', config = function() - require("dressing").setup { - input = { - insert_only = false - } - } - end + require("dressing").setup { input = { insert_only = false } } + end, }, { "kylechui/nvim-surround", tag = "*", -- Use for stability; omit to use `main` branch for the latest features - config = function() - require("nvim-surround").setup() - end + config = function() require("nvim-surround").setup() end, }, { - "catppuccin/nvim", as = "catppuccin", + "catppuccin/nvim", + as = "catppuccin", config = function() local cp = require("catppuccin.palettes").get_palette() @@ -262,14 +266,8 @@ lvim.plugins = { integrations = { ts_rainbow = true, which_key = true, - dap = { - enabled = true, - enable_ui = true, - }, - navic = { - enabled = true, - custom_bg = "NONE", - }, + dap = { enabled = true, enable_ui = true }, + navic = { enabled = true, custom_bg = "NONE" }, }, color_overrides = { mocha = { @@ -287,16 +285,15 @@ lvim.plugins = { TelescopeBorder = { link = "FloatBorder" }, TelescopeMatching = { link = "TelescopeNormal" }, TelescopeSelection = { fg = "NONE", bg = cp.surface0 }, - TelescopeTitle = { fg = cp.subtext0 } + TelescopeTitle = { fg = cp.subtext0 }, }, }) vim.api.nvim_command "colorscheme catppuccin" - end - } + end, + }, } - -- SOME PROPER CUSTOM CONFIGURATION -- vim.api.nvim_create_autocmd("BufWritePost", {