Skip to content

Instantly share code, notes, and snippets.

@shurizzle
Created October 23, 2022 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shurizzle/159cf07cdb409e5e16240ba6764478db to your computer and use it in GitHub Desktop.
Save shurizzle/159cf07cdb409e5e16240ba6764478db to your computer and use it in GitHub Desktop.
LunarVim js config
--[[
lvim is the global options object
Linters should be
filled in as strings with either
a global executable or a path to
an executable
]]
-- THESE ARE EXAMPLE CONFIGS FEEL FREE TO CHANGE TO WHATEVER YOU WANT
vim.opt.relativenumber = true
-- general
lvim.log.level = "warn"
lvim.format_on_save = true
lvim.colorscheme = "tokyonight"
lvim.use_icons = true
-- keymappings [view all the defaults by pressing <leader>Lk]
lvim.leader = "space"
-- add your own keymapping
lvim.keys.normal_mode["<C-s>"] = ":w<cr>"
-- lvim.keys.normal_mode["<S-l>"] = ":BufferLineCycleNext<CR>"
-- lvim.keys.normal_mode["<S-h>"] = ":BufferLineCyclePrev<CR>"
-- unmap a default keymapping
-- vim.keymap.del("n", "<C-Up>")
-- override a default keymapping
-- lvim.keys.normal_mode["<C-q>"] = ":q<cr>" -- or vim.keymap.set("n", "<C-q>", ":q<cr>" )
-- Change Telescope navigation to use j and k for navigation and n and p for history in both input and normal mode.
-- we use protected-mode (pcall) just in case the plugin wasn't loaded yet.
-- local _, actions = pcall(require, "telescope.actions")
-- lvim.builtin.telescope.defaults.mappings = {
-- -- for input mode
-- i = {
-- ["<C-j>"] = actions.move_selection_next,
-- ["<C-k>"] = actions.move_selection_previous,
-- ["<C-n>"] = actions.cycle_history_next,
-- ["<C-p>"] = actions.cycle_history_prev,
-- },
-- -- for normal mode
-- n = {
-- ["<C-j>"] = actions.move_selection_next,
-- ["<C-k>"] = actions.move_selection_previous,
-- },
-- }
-- Change theme settings
-- lvim.builtin.theme.options.dim_inactive = true
-- lvim.builtin.theme.options.style = "storm"
-- Use which-key to add extra bindings with the leader-key prefix
-- lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" }
-- lvim.builtin.which_key.mappings["t"] = {
-- name = "+Trouble",
-- r = { "<cmd>Trouble lsp_references<cr>", "References" },
-- f = { "<cmd>Trouble lsp_definitions<cr>", "Definitions" },
-- d = { "<cmd>Trouble document_diagnostics<cr>", "Diagnostics" },
-- q = { "<cmd>Trouble quickfix<cr>", "QuickFix" },
-- l = { "<cmd>Trouble loclist<cr>", "LocationList" },
-- w = { "<cmd>Trouble workspace_diagnostics<cr>", "Workspace Diagnostics" },
-- }
lvim.builtin.alpha.active = true
lvim.builtin.alpha.mode = "dashboard"
lvim.builtin.notify.active = true
lvim.builtin.terminal.active = true
lvim.builtin.nvimtree.setup.view.side = "left"
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
lvim.builtin.comment.active = true
lvim.builtin.gitsigns.active = true
-- if you don't want all the parsers change this to a table of the ones you want
lvim.builtin.treesitter.ensure_installed = {
"bash",
"lua",
"python",
"yaml",
"css",
"html",
"javascript",
"typescript",
"tsx",
"json",
"vue",
"svelte",
}
lvim.builtin.treesitter.ignore_install = { "haskell", "comment" }
lvim.builtin.treesitter.highlight.enable = true
lvim.builtin.treesitter.textobjects = {
swap = {
enable = false,
},
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
}
-- generic LSP settings
lvim.lsp.installer.setup.ensure_installed = {
"lua-language-server",
"vue-language-server",
"typescript-language-server",
"svelte-language-server",
"eslint-lsp",
"prettierd",
}
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "tsserver", "eslint" })
require("lvim.lsp.manager").setup("eslint", {
on_attach = function(client, _)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
settings = {
format = false,
},
})
local formatters = require("lvim.lsp.null-ls.formatters")
formatters.setup({
{
command = "prettierd",
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
"vue",
"svelte",
},
},
})
-- Additional Plugins
lvim.plugins = {
-- {
-- "folke/trouble.nvim",
-- cmd = "TroubleToggle",
-- },
{
"jose-elias-alvarez/typescript.nvim",
config = function()
require("typescript").setup({
server = { -- pass options to lspconfig's setup method
on_attach = function(client, _)
client.server_capabilities.documentFormattingProvider = false
client.server_capabilities.documentRangeFormattingProvider = false
end,
},
})
end,
},
{ "tpope/vim-repeat" },
{ "tpope/vim-surround" },
}
-- Just use vim.
for name, key in pairs({ "Left", "Right", "Up", "Down", "PageUp", "PageDown", "End", "Home", Delete = "Del" }) do
if type(name) == "number" then
name = key
end
local keymap = function(modes, left, right, options)
options = vim.tbl_extend("force", { noremap = true, silent = true }, options or {})
vim.keymap.set(modes, left, right, options)
end
keymap("n", "<" .. key .. ">", '<cmd>echo "No ' .. name .. ' for you!"<CR>', { noremap = false })
keymap("v", "<" .. key .. ">", '<cmd><C-u>echo "No ' .. name .. ' for you!"<CR>', { noremap = false })
keymap("i", "<" .. key .. ">", '<C-o><cmd>echo "No ' .. name .. ' for you!"<CR>', { noremap = false })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment