Last active
June 4, 2023 12:51
-
-
Save colinaaa/9ef6ed7c26e603b2921cfb65d3dc3bf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
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 | |
-- general | |
lvim.format_on_save = false | |
lvim.lint_on_save = true | |
lvim.colorscheme = "onedark" | |
-- keymappings | |
lvim.leader = "space" | |
lvim.keys.normal_mode["<S-l>"] = ":BufferLineCycleNext<CR>" | |
lvim.keys.normal_mode["<S-h>"] = ":BufferLineCyclePrev<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, | |
}, | |
} | |
-- overwrite the key-mappings provided by LunarVim for any mode, or leave it empty to keep them | |
-- lvim.keys.normal_mode = { | |
-- Page down/up | |
-- {'[d', '<PageUp>'}, | |
-- {']d', '<PageDown>'}, | |
-- Navigate buffers | |
-- {'<Tab>', ':bnext<CR>'}, | |
-- {'<S-Tab>', ':bprevious<CR>'}, | |
-- } | |
-- if you just want to augment the existing ones then use the utility function | |
-- require("lv-utils").add_keymap_insert_mode({ silent = true }, { | |
-- { "<C-s>", ":w<cr>" }, | |
-- { "<C-c>", "<ESC>" }, | |
-- }) | |
-- you can also use the native vim way directly | |
-- vim.api.nvim_set_keymap("i", "<C-Space>", "compe#complete()", { noremap = true, silent = true, expr = true }) | |
-- After changing plugin config exit and reopen LunarVim, Run :PackerInstall :PackerCompile | |
lvim.builtin.alpha.active = true | |
lvim.builtin.alpha.mode = "dashboard" | |
lvim.builtin.terminal.active = true | |
lvim.builtin.terminal.open_mapping = [[<c-q>]] | |
lvim.builtin.nvimtree.side = "left" | |
lvim.builtin.nvimtree.setup.renderer.icons.show.git = true | |
lvim.builtin.nvimtree.setup.renderer.icons.show.file = true | |
-- if you don't want all the parsers change this to a table of the ones you want | |
lvim.builtin.treesitter.ensure_installed = "all" | |
lvim.builtin.treesitter.ignore_install = { "haskell", "smali" } | |
lvim.builtin.treesitter.highlight.enabled = true | |
-- generic LSP settings | |
lvim.lsp.installer.setup.automatic_installation = true | |
-- -- make sure server will always be installed even if the server is in skipped_servers list | |
-- lvim.lsp.installer.setup.ensure_installed = { | |
-- "sumneko_lua", | |
-- "jsonls", | |
-- } | |
-- -- change UI setting of `LspInstallInfo` | |
-- -- see <https://github.com/williamboman/nvim-lsp-installer#default-configuration> | |
-- lvim.lsp.installer.setup.ui.check_outdated_servers_on_open = false | |
-- lvim.lsp.installer.setup.ui.border = "rounded" | |
-- lvim.lsp.installer.setup.ui.keymaps = { | |
-- uninstall_server = "d", | |
-- toggle_server_expand = "o", | |
-- } | |
-- ---@usage disable automatic installation of servers | |
-- lvim.lsp.installer.setup.automatic_installation = false | |
-- ---configure a server manually. !!Requires `:LvimCacheReset` to take effect!! | |
-- ---see the full default list `:lua print(vim.inspect(lvim.lsp.automatic_configuration.skipped_servers))` | |
-- vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "pyright" }) | |
-- local opts = {} -- check the lspconfig documentation for a list of all possible options | |
-- require("lvim.lsp.manager").setup("pyright", opts) | |
-- ---remove a server from the skipped list, e.g. eslint, or emmet_ls. !!Requires `:LvimCacheReset` to take effect!! | |
-- ---`:LvimInfo` lists which server(s) are skipped for the current filetype | |
-- lvim.lsp.automatic_configuration.skipped_servers = vim.tbl_filter(function(server) | |
-- return server ~= "emmet_ls" | |
-- end, lvim.lsp.automatic_configuration.skipped_servers) | |
-- -- you can set a custom on_attach function that will be used for all the language servers | |
-- -- See <https://github.com/neovim/nvim-lspconfig#keybindings-and-completion> | |
-- lvim.lsp.on_attach_callback = function(client, bufnr) | |
-- local function buf_set_option(...) | |
-- vim.api.nvim_buf_set_option(bufnr, ...) | |
-- end | |
-- --Enable completion triggered by <c-x><c-o> | |
-- 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 = "prettier", | |
---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. | |
-- filetypes = { "typescript", "typescriptreact" }, | |
}, | |
{ | |
exe = "stylua", | |
filetypes = { "lua" }, | |
}, | |
{ command = "black", filetypes = { "python" } }, | |
}) | |
-- -- set additional linters | |
local linters = require("lvim.lsp.null-ls.linters") | |
linters.setup({ | |
{ command = "flake8", filetypes = { "python" } }, | |
{ | |
-- each linter accepts a list of options identical to https://github.com/jose-elias-alvarez/null-ls.nvim/blob/main/doc/BUILTINS.md#Configuration | |
command = "shellcheck", | |
---@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 = { "--severity", "warning" }, | |
}, | |
{ | |
command = "codespell", | |
---@usage specify which filetypes to enable. By default a providers will attach to all the filetypes it supports. | |
-- filetypes = { "javascript", "python", "markdown", "c++" }, | |
}, | |
{ | |
command = "eslint", | |
}, | |
}) | |
-- local linters = require "lvim.lsp.null-ls.linters" | |
-- linters.setup { | |
-- python | |
lvim.plugins = { | |
{ "navarasu/onedark.nvim" }, | |
{ "gennaro-tedesco/nvim-jqx", cmd = { "JqxList", "JqxQuery" }, ft = "json" }, | |
{ | |
"ethanholz/nvim-lastplace", | |
config = function() | |
require("nvim-lastplace").setup({ | |
lastplace_ignore_buftype = { "quickfix", "nofile", "help" }, | |
lastplace_ignore_filetype = { "gitcommit", "gitrebase", "svn", "hgcommit" }, | |
lastplace_open_folds = true, | |
}) | |
end, | |
}, | |
{ | |
"rmagatti/goto-preview", | |
config = function() | |
require("goto-preview").setup({ | |
width = 120, -- Width of the floating window | |
height = 25, -- Height of the floating window | |
default_mappings = true, -- Bind default mappings | |
debug = false, -- Print debug information | |
opacity = nil, -- 0-100 opacity level of the floating window where 100 is fully transparent. | |
post_open_hook = nil, -- A function taking two arguments, a buffer and a window to be ran as a hook. | |
-- You can use "default_mappings = true" setup option | |
-- Or explicitly set keybindings | |
-- vim.cmd("nnoremap gpd <cmd>lua require('goto-preview').goto_preview_definition()<CR>") | |
-- vim.cmd("nnoremap gpi <cmd>lua require('goto-preview').goto_preview_implementation()<CR>") | |
-- vim.cmd("nnoremap gP <cmd>lua require('goto-preview').close_all_win()<CR>") | |
}) | |
end, | |
}, | |
{ | |
"folke/trouble.nvim", | |
cmd = "TroubleToggle", | |
}, | |
{ | |
"ggandor/lightspeed.nvim", | |
event = "BufRead", | |
}, | |
{ | |
"nacro90/numb.nvim", | |
event = "BufRead", | |
config = function() | |
require("numb").setup({ | |
show_numbers = true, -- Enable 'number' for the window while peeking | |
show_cursorline = true, -- Enable 'cursorline' for the window while peeking | |
}) | |
end, | |
}, | |
{ | |
"windwp/nvim-ts-autotag", | |
event = "InsertEnter", | |
config = function() | |
require("nvim-ts-autotag").setup() | |
end, | |
}, | |
{ | |
"p00f/nvim-ts-rainbow", | |
}, | |
{ | |
"norcalli/nvim-colorizer.lua", | |
config = function() | |
require("colorizer").setup({ "*" }, { | |
RGB = true, -- #RGB hex codes | |
RRGGBB = true, -- #RRGGBB hex codes | |
RRGGBBAA = true, -- #RRGGBBAA hex codes | |
rgb_fn = true, -- CSS rgb() and rgba() functions | |
hsl_fn = true, -- CSS hsl() and hsla() functions | |
css = true, -- Enable all CSS features: rgb_fn, hsl_fn, names, RGB, RRGGBB | |
css_fn = true, -- Enable all CSS *functions*: rgb_fn, hsl_fn | |
}) | |
end, | |
}, | |
{ | |
"ray-x/lsp_signature.nvim", | |
event = "InsertEnter", | |
config = function() | |
require("lsp_signature").setup() | |
end, | |
}, | |
{ | |
"simrat39/symbols-outline.nvim", | |
cmd = "SymbolsOutline", | |
}, | |
{ | |
"folke/persistence.nvim", | |
event = "VimEnter", | |
lazy = true, | |
config = function() | |
require("persistence").setup({ | |
dir = vim.fn.expand(vim.fn.stdpath("config") .. "/session/"), | |
options = { "buffers", "curdir", "tabpages", "winsize" }, | |
}) | |
end, | |
}, | |
{ | |
"folke/todo-comments.nvim", | |
event = "BufRead", | |
}, | |
{ | |
"f-person/git-blame.nvim", | |
event = "BufRead", | |
config = function() | |
vim.cmd("highlight default link gitblame SpecialComment") | |
vim.g.gitblame_enabled = 0 | |
end, | |
}, | |
{ | |
"tpope/vim-surround", | |
keys = { "c", "d", "y" }, | |
}, | |
{ | |
"ruifm/gitlinker.nvim", | |
event = "BufRead", | |
config = function() | |
require("gitlinker").setup({ | |
mappings = nil, | |
opts = { | |
-- remote = "code.byted.org", -- force the use of a specific remote | |
-- adds current line nr in the url for normal mode | |
add_current_line_on_normal_mode = true, | |
-- callback for what to do with the url | |
action_callback = require("gitlinker.actions").copy_to_clipboard, | |
-- print the url after performing the action | |
print_url = false, | |
}, | |
callbacks = { | |
["byted.org"] = function(url_data) | |
local url = "https://" .. url_data.host .. "/" .. url_data.repo | |
if not url_data.file or not url_data.rev then | |
return url | |
end | |
url = url .. "/blob/" .. url_data.rev .. "/" .. url_data.file | |
if not url_data.lstart then | |
return url | |
end | |
url = url .. "#L" .. url_data.lstart | |
if url_data.lend then | |
url = url .. "-" .. url_data.lend | |
end | |
return url | |
end, | |
}, | |
}) | |
end, | |
dependencies = "nvim-lua/plenary.nvim", | |
}, | |
} | |
lvim.builtin.which_key.mappings["t"] = { | |
name = "+Trouble", | |
t = { "<cmd>TroubleToggle<cr>", "trouble" }, | |
w = { "<cmd>TroubleToggle lsp_workspace_diagnostics<cr>", "workspace" }, | |
d = { "<cmd>TroubleToggle lsp_document_diagnostics<cr>", "document" }, | |
q = { "<cmd>TroubleToggle quickfix<cr>", "quickfix" }, | |
l = { "<cmd>TroubleToggle loclist<cr>", "loclist" }, | |
r = { "<cmd>TroubleToggle lsp_references<cr>", "references" }, | |
} | |
lvim.builtin.which_key.mappings["P"] = { "<cmd>Telescope projects<CR>", "Projects" } | |
lvim.builtin.which_key.mappings["Q"] = { | |
name = "+Quit", | |
s = { "<cmd>lua require('persistence').load()<cr>", "Restore for current dir" }, | |
l = { "<cmd>lua require('persistence').load({last=true})<cr>", "Restore last session" }, | |
d = { "<cmd>lua require('persistence').stop()<cr>", "Quit without saving session" }, | |
} | |
lvim.keys.normal_mode["<C-v>"] = nil | |
lvim.builtin.which_key.mappings["gy"] = { | |
"<cmd>lua require'gitlinker'.get_buf_range_url('n')<cr>", | |
"Get git link", | |
} | |
lvim.builtin.which_key.vmappings["gy"] = { | |
"<cmd>lua require'gitlinker'.get_buf_range_url('v')<cr>", | |
"Get git link", | |
} | |
-- Autocommands (https://neovim.io/doc/user/autocmd.html) | |
vim.api.nvim_create_autocmd("BufEnter", { | |
pattern = { "*.json", "*.jsonc" }, | |
-- enable wrap mode for json files only | |
command = "setlocal wrap", | |
}) | |
vim.api.nvim_create_autocmd("FileType", { | |
pattern = "zsh", | |
callback = function() | |
-- let treesitter use bash highlight for zsh files as well | |
require("nvim-treesitter.highlight").attach(0, "bash") | |
end, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment