|
| 1 | +--[[ |
| 2 | +lvim is the global options object |
| 3 | +
|
| 4 | +Linters should be |
| 5 | +filled in as strings with either |
| 6 | +a global executable or a path to |
| 7 | +an executable |
| 8 | +]] |
| 9 | +-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT |
| 10 | + |
| 11 | +-- general |
| 12 | +lvim.log.level = "warn" |
| 13 | +lvim.format_on_save = true |
| 14 | +vim.g.material_style = "deep ocean" |
| 15 | +lvim.colorscheme = "material" |
| 16 | + |
| 17 | +-- keymappings [view all the defaults by pressing <leader>Lk] |
| 18 | +lvim.leader = "space" |
| 19 | +-- add your own keymapping |
| 20 | +lvim.keys.normal_mode["<C-s>"] = ":update<cr>" |
| 21 | +lvim.keys.insert_mode["<C-s>"] = "<Esc>:update<cr>" |
| 22 | +-- unmap a default keymapping |
| 23 | +lvim.keys.normal_mode["<S-l>"] = false |
| 24 | +lvim.keys.normal_mode["<S-h>"] = false |
| 25 | +-- lvim.keys.normal_mode["<C-Up>"] = false |
| 26 | +-- edit a default keymapping |
| 27 | +-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" |
| 28 | + |
| 29 | +-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode. |
| 30 | +-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet. |
| 31 | +local _, actions = pcall(require, "telescope.actions") |
| 32 | +lvim.builtin.telescope.defaults.mappings = { |
| 33 | + -- for input mode |
| 34 | + i = { |
| 35 | + ["<C-j>"] = actions.move_selection_next, |
| 36 | + ["<C-k>"] = actions.move_selection_previous, |
| 37 | + ["<C-n>"] = actions.cycle_history_next, |
| 38 | + ["<C-p>"] = actions.cycle_history_prev, |
| 39 | + }, |
| 40 | + -- for normal mode |
| 41 | + n = { |
| 42 | + ["<C-j>"] = actions.move_selection_next, |
| 43 | + ["<C-k>"] = actions.move_selection_previous, |
| 44 | + }, |
| 45 | +} |
| 46 | + |
| 47 | +-- Use which-key to add extra bindings with the leader-key prefix |
| 48 | +-- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" } |
| 49 | +-- lvim.builtin.which_key.mappings["t"] = { |
| 50 | +-- name = "+Trouble", |
| 51 | +-- r = { "<cmd>Trouble lsp_references<cr>", "References" }, |
| 52 | +-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" }, |
| 53 | +-- d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnostics" }, |
| 54 | +-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" }, |
| 55 | +-- l = { "<cmd>Trouble loclist<cr>", "LocationList" }, |
| 56 | +-- w = { "<cmd>Trouble workspace_diagnostics<cr>", "Wordspace Diagnostics" }, |
| 57 | +-- } |
| 58 | + |
| 59 | +-- TODO: User Config for predefined plugins |
| 60 | +-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile |
| 61 | +lvim.builtin.alpha.active = true |
| 62 | +lvim.builtin.alpha.mode = "dashboard" |
| 63 | +lvim.builtin.terminal.active = true |
| 64 | +lvim.builtin.nvimtree.setup.view.side = "left" |
| 65 | +lvim.builtin.nvimtree.setup.renderer.icons.show.git = false |
| 66 | + |
| 67 | +-- if you don't want all the parsers change this to a table of the ones you want |
| 68 | +lvim.builtin.treesitter.ensure_installed = { |
| 69 | + "bash", |
| 70 | + "c", |
| 71 | + "javascript", |
| 72 | + "json", |
| 73 | + "lua", |
| 74 | + "python", |
| 75 | + "typescript", |
| 76 | + "tsx", |
| 77 | + "css", |
| 78 | + "rust", |
| 79 | + "java", |
| 80 | + "yaml", |
| 81 | + "svelte", |
| 82 | +} |
| 83 | + |
| 84 | +lvim.builtin.treesitter.ignore_install = { "haskell" } |
| 85 | +lvim.builtin.treesitter.highlight.enabled = true |
| 86 | + |
| 87 | +-- generic LSP settings |
| 88 | + |
| 89 | +-- ---@usage disable automatic installation of servers |
| 90 | +-- lvim.lsp.automatic_servers_installation = false |
| 91 | + |
| 92 | +-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! |
| 93 | +-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` |
| 94 | +-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" }) |
| 95 | +-- local opts = {} -- check the lspconfig documentation for a list of all possible options |
| 96 | +-- require("lvim.lsp.manager").setup("pyright", opts) |
| 97 | + |
| 98 | +-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! |
| 99 | +-- ---`:LvimInfo` lists which server(s) are skiipped for the current filetype |
| 100 | +-- vim.tbl_map(function(server) |
| 101 | +-- return server ~= "emmet_ls" |
| 102 | +-- end, lvim.lsp.automatic_configuration.skipped_servers) |
| 103 | + |
| 104 | +-- -- you can set a custom on_attach function that will be used for all the language servers |
| 105 | +-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion> |
| 106 | +-- lvim.lsp.on_attach_callback = function(client, bufnr) |
| 107 | +-- local function buf_set_option(...) |
| 108 | +-- vim.api.nvim_buf_set_option(bufnr, ...) |
| 109 | +-- end |
| 110 | +-- --Enable completion triggered by <c-x><c-o> |
| 111 | +-- buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc") |
| 112 | +-- end |
| 113 | + |
| 114 | +-- set a formatter, this will override the language server formatting capabilities (if it exists) |
| 115 | +local formatters = require "lvim.lsp.null-ls.formatters" |
| 116 | +formatters.setup { |
| 117 | + -- { command = "black", filetypes = { "python" } }, |
| 118 | + -- { command = "isort", filetypes = { "python" } }, |
| 119 | + -- { |
| 120 | + -- command = "eslint_d", |
| 121 | + -- filetypes = { |
| 122 | + -- "javascript", |
| 123 | + -- "typescript", |
| 124 | + -- "typescriptreact", |
| 125 | + -- "javascriptreact", |
| 126 | + -- "svelte", |
| 127 | + -- "vue", |
| 128 | + -- } |
| 129 | + -- }, |
| 130 | + { |
| 131 | + -- each formatter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration |
| 132 | + command = "prettierd", |
| 133 | + ---@usage arguments to pass to the formatter |
| 134 | + -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` |
| 135 | + -- extra_args = { "--print-with", "100" }, |
| 136 | + ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. |
| 137 | + filetypes = { |
| 138 | + "javascript", |
| 139 | + "typescript", |
| 140 | + "typescriptreact", |
| 141 | + "javascriptreact", |
| 142 | + "svelte", |
| 143 | + "vue", |
| 144 | + "html", |
| 145 | + "css", |
| 146 | + "markdown", |
| 147 | + } |
| 148 | + }, |
| 149 | +} |
| 150 | + |
| 151 | +-- -- set additional linters |
| 152 | +local linters = require "lvim.lsp.null-ls.linters" |
| 153 | +linters.setup { |
| 154 | + { |
| 155 | + command = "eslint_d", |
| 156 | + filetypes = { |
| 157 | + "javascript", |
| 158 | + "typescript", |
| 159 | + "typescriptreact", |
| 160 | + "javascriptreact", |
| 161 | + "svelte", |
| 162 | + "vue", |
| 163 | + } |
| 164 | + }, |
| 165 | + -- { |
| 166 | + -- -- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration |
| 167 | + -- command = "shellcheck", |
| 168 | + -- ---@usage arguments to pass to the formatter |
| 169 | + -- -- these cannot contain whitespaces, options such as `--line-width 80` become either `{'--line-width', '80'}` or `{'--line-width=80'}` |
| 170 | + -- extra_args = { "--severity", "warning" }, |
| 171 | + -- }, |
| 172 | + -- { |
| 173 | + -- command = "codespell", |
| 174 | + -- ---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. |
| 175 | + -- filetypes = { "javascript", "python" }, |
| 176 | + -- }, |
| 177 | +} |
| 178 | + |
| 179 | +-- Additional Plugins |
| 180 | +lvim.plugins = { |
| 181 | + { "sainnhe/sonokai" }, |
| 182 | + { "marko-cerovac/material.nvim" }, |
| 183 | + { "Shatur/neovim-ayu" }, |
| 184 | + -- { |
| 185 | + -- "aca/emmet-ls", |
| 186 | + -- config = function() |
| 187 | + -- local lspconfig = require("lspconfig") |
| 188 | + -- local configs = require("lspconfig/configs") |
| 189 | + -- |
| 190 | + -- local capabilities = vim.lsp.protocol.make_client_capabilities() |
| 191 | + -- capabilities.textDocument.completion.completionItem.snippetSupport = true |
| 192 | + -- -- capabilities.textDocument.completion.completionItem.resolveSupport = { |
| 193 | + -- -- properties = { |
| 194 | + -- -- "documentation", |
| 195 | + -- -- "detail", |
| 196 | + -- -- "additionalTextEdits", |
| 197 | + -- -- }, |
| 198 | + -- -- } |
| 199 | + -- |
| 200 | + -- if not lspconfig.emmet_ls then |
| 201 | + -- configs.emmet_ls = { |
| 202 | + -- default_config = { |
| 203 | + -- cmd = { "emmet-ls", "--stdio" }, |
| 204 | + -- filetypes = { |
| 205 | + -- "html", |
| 206 | + -- "css", |
| 207 | + -- "javascript", |
| 208 | + -- "typescript", |
| 209 | + -- "typescriptreact", |
| 210 | + -- "javascriptreact", |
| 211 | + -- "svelte", |
| 212 | + -- "vue", |
| 213 | + -- }, |
| 214 | + -- root_dir = function(fname) |
| 215 | + -- return vim.loop.cwd() |
| 216 | + -- end, |
| 217 | + -- settings = {}, |
| 218 | + -- }, |
| 219 | + -- } |
| 220 | + -- end |
| 221 | + -- lspconfig.emmet_ls.setup({ capabilities = capabilities }) |
| 222 | + -- end, |
| 223 | + -- }, |
| 224 | +} |
| 225 | + |
| 226 | +-- Autocommands (https://neovim.io/doc/user/autocmd.html) |
| 227 | +-- lvim.autocommands.custom_groups = { |
| 228 | +-- { "BufWinEnter", "*.lua", "setlocal ts=8 sw=8" }, |
| 229 | +-- } |
| 230 | + |
| 231 | +-- Autocommand create folder(s) for new file |
| 232 | +vim.cmd 'source ~/.config/lvim/vimrc-auto-mkdir.vim' |
0 commit comments