Lvim config rework
This commit is contained in:
351
lvim/config.lua
351
lvim/config.lua
@@ -1,14 +1,10 @@
|
||||
--[[
|
||||
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
|
||||
-- Read the docs: https://www.lunarvim.org/docs/configuration
|
||||
-- Example configs: https://github.com/LunarVim/starter.lvim
|
||||
-- Video Tutorials: https://www.youtube.com/watch?v=sFA9kX-Ud_c&list=PLhoH5vyxr6QqGu0i7tt_XoVK9v-KvZ3m6
|
||||
-- Forum: https://www.reddit.com/r/lunarvim/
|
||||
-- Discord: https://discord.com/invite/Xb9B4Ny
|
||||
--
|
||||
-- General
|
||||
lvim.log.level = "warn"
|
||||
lvim.format_on_save = false
|
||||
lvim.colorscheme = "onedark"
|
||||
@@ -20,13 +16,14 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "cpp",
|
||||
command = "setlocal shiftwidth=2 tabstop=2"
|
||||
})
|
||||
-- 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.builtin.terminal.open_mapping = "<c-t>"
|
||||
lvim.builtin.treesitter.ensure_installed = {
|
||||
"lua",
|
||||
"rust",
|
||||
"toml",
|
||||
}
|
||||
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
|
||||
|
||||
-- Use which-key to add extra bindings with the leader-key prefix
|
||||
-- Keybind
|
||||
lvim.builtin.which_key.mappings["g"].g = { "<cmd>ToggleTerm<cr><cmd>TermExec cmd='gitui&&exit'<CR>", "Gitui" }
|
||||
lvim.builtin.which_key.mappings["s"].B = { "<cmd>Telescope git_branches<CR>", "Checkout branch" }
|
||||
lvim.builtin.which_key.mappings["s"].b = { "<cmd>Telescope buffers<CR>", "Buffer" }
|
||||
@@ -37,45 +34,36 @@ lvim.builtin.which_key.mappings["t"] = {
|
||||
t = { "<cmd>ToggleTerm size=15 direction=horizontal<cr>", "Split horizontal" },
|
||||
}
|
||||
|
||||
-- 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.terminal.active = true
|
||||
lvim.builtin.nvimtree.setup.view.side = "left"
|
||||
lvim.builtin.nvimtree.setup.renderer.icons.show.git = false
|
||||
|
||||
-- if you don't want all the parsers change this to a table of the ones you want
|
||||
lvim.builtin.treesitter.ensure_installed = {
|
||||
"bash",
|
||||
"json",
|
||||
"lua",
|
||||
"python",
|
||||
"typescript",
|
||||
"rust",
|
||||
"java",
|
||||
"toml",
|
||||
}
|
||||
|
||||
lvim.builtin.treesitter.highlight.enabled = true
|
||||
|
||||
|
||||
-- Additional Plugins
|
||||
-- Plugins
|
||||
lvim.plugins = {
|
||||
--RUST
|
||||
"simrat39/rust-tools.nvim",
|
||||
{
|
||||
"saecki/crates.nvim",
|
||||
version = "v0.3.0",
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
require("crates").setup {
|
||||
null_ls = {
|
||||
enabled = true,
|
||||
name = "crates.nvim",
|
||||
},
|
||||
popup = {
|
||||
border = "rounded",
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
{ "slint-ui/vim-slint" },
|
||||
-- General
|
||||
{
|
||||
"j-hui/fidget.nvim",
|
||||
config = function()
|
||||
require("fidget").setup()
|
||||
end,
|
||||
},
|
||||
{ "navarasu/onedark.nvim" },
|
||||
{ "folke/tokyonight.nvim" },
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
cmd = "TroubleToggle",
|
||||
},
|
||||
{
|
||||
"Pocco81/auto-save.nvim",
|
||||
config = function()
|
||||
@@ -89,86 +77,23 @@ lvim.plugins = {
|
||||
"iamcco/markdown-preview.nvim",
|
||||
build = function() vim.fn["mkdp#util#install"]() end,
|
||||
},
|
||||
-- :Rust
|
||||
{
|
||||
'saecki/crates.nvim',
|
||||
-- ft = {"toml"},
|
||||
config = function(_, opts)
|
||||
local crates = require('crates')
|
||||
crates.setup({
|
||||
null_ls = {
|
||||
enabled = true,
|
||||
name = "crates.nvim",
|
||||
},
|
||||
})
|
||||
require('cmp').setup.buffer({
|
||||
sources = { { name = "crates" } }
|
||||
})
|
||||
crates.show()
|
||||
end,
|
||||
},
|
||||
{
|
||||
"simrat39/rust-tools.nvim",
|
||||
-- ft = { "rust", "rs" }, -- IMPORTANT: re-enabling this seems to break inlay-hints
|
||||
config = function()
|
||||
require("rust-tools").setup {
|
||||
tools = {
|
||||
executor = require("rust-tools/executors").termopen, -- can be quickfix or termopen
|
||||
reload_workspace_from_cargo_toml = true,
|
||||
inlay_hints = {
|
||||
auto = true,
|
||||
only_current_line = false,
|
||||
show_parameter_hints = true,
|
||||
parameter_hints_prefix = "<-",
|
||||
other_hints_prefix = ":",
|
||||
max_len_align = false,
|
||||
max_len_align_padding = 1,
|
||||
right_align = false,
|
||||
right_align_padding = 7,
|
||||
highlight = "Comment",
|
||||
},
|
||||
hover_actions = {
|
||||
border = {
|
||||
{ "╭", "FloatBorder" },
|
||||
{ "─", "FloatBorder" },
|
||||
{ "╮", "FloatBorder" },
|
||||
{ "│", "FloatBorder" },
|
||||
{ "╯", "FloatBorder" },
|
||||
{ "─", "FloatBorder" },
|
||||
{ "╰", "FloatBorder" },
|
||||
{ "│", "FloatBorder" },
|
||||
},
|
||||
auto_focus = true,
|
||||
},
|
||||
},
|
||||
server = {
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
checkOnSave = {
|
||||
command = "clippy",
|
||||
}
|
||||
}
|
||||
},
|
||||
on_init = require("lvim.lsp").common_on_init,
|
||||
on_attach = function(client, bufnr)
|
||||
require("lvim.lsp").common_on_attach(client, bufnr)
|
||||
local rt = require "rust-tools"
|
||||
-- Hover actions
|
||||
vim.keymap.set("n", "<C-space>", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
-- Code action groups
|
||||
vim.keymap.set("n", "<leader>lA", rt.code_action_group.code_action_group, { buffer = bufnr })
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
{ "slint-ui/vim-slint" },
|
||||
-- Java
|
||||
{ 'hdiniz/vim-gradle' },
|
||||
{ "mfussenegger/nvim-jdtls", },
|
||||
-- Deno
|
||||
{ 'sigmasd/deno-nvim' }
|
||||
}
|
||||
|
||||
-- Themes
|
||||
require('onedark').setup {
|
||||
style = 'darker', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
|
||||
toggle_style_key = "<leader>ss",
|
||||
transparent = false, -- Show/hide background
|
||||
|
||||
code_style = {
|
||||
comments = 'italic',
|
||||
keywords = 'italic,',
|
||||
functions = 'bold',
|
||||
strings = 'none',
|
||||
variables = 'none'
|
||||
},
|
||||
}
|
||||
|
||||
-- folding
|
||||
vim.o.foldcolumn = '2' -- '0' is not bad
|
||||
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
|
||||
@@ -213,66 +138,118 @@ for _, ls in ipairs(language_servers) do
|
||||
})
|
||||
end
|
||||
require('ufo').setup()
|
||||
-- RUST CONFIG
|
||||
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "rust_analyzer" })
|
||||
|
||||
-- Java
|
||||
vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "jdtls" })
|
||||
local lspconfig = require('lspconfig')
|
||||
local lombok = vim.fn.stdpath('data') .. '/mason/packages/jdtls/lombok.jar'
|
||||
lspconfig.jdtls.setup { cmd = { "jdtls", "--jvm-arg=-javaagent:" .. lombok } }
|
||||
local mason_path = vim.fn.glob(vim.fn.stdpath "data" .. "/mason/")
|
||||
|
||||
-- Deno
|
||||
local nvim_lsp = require("lspconfig")
|
||||
nvim_lsp.denols.setup {
|
||||
on_attach = on_attach,
|
||||
root_dir = nvim_lsp.util.root_pattern("deno.jsonc", "deno.json"),
|
||||
init_options = {
|
||||
lint = true,
|
||||
},
|
||||
}
|
||||
nvim_lsp.tsserver.setup {
|
||||
on_attach = on_attach,
|
||||
root_dir = nvim_lsp.util.root_pattern("package.json"),
|
||||
single_file_support = false
|
||||
}
|
||||
local codelldb_path = mason_path .. "bin/codelldb"
|
||||
local liblldb_path = mason_path .. "packages/codelldb/extension/lldb/lib/liblldb"
|
||||
local this_os = vim.loop.os_uname().sysname
|
||||
|
||||
require("deno-nvim").setup({
|
||||
server = {
|
||||
on_attach = ...,
|
||||
capabilites = ...
|
||||
},
|
||||
-- if you're using dap to debug (see the README for more info)
|
||||
dap = {
|
||||
adapter = ...
|
||||
-- The path in windows is different
|
||||
if this_os:find "Windows" then
|
||||
codelldb_path = mason_path .. "packages\\codelldb\\extension\\adapter\\codelldb.exe"
|
||||
liblldb_path = mason_path .. "packages\\codelldb\\extension\\lldb\\bin\\liblldb.dll"
|
||||
else
|
||||
-- The liblldb extension is .so for linux and .dylib for macOS
|
||||
liblldb_path = liblldb_path .. (this_os == "Linux" and ".so" or ".dylib")
|
||||
end
|
||||
|
||||
pcall(function()
|
||||
require("rust-tools").setup {
|
||||
tools = {
|
||||
executor = require("rust-tools/executors").termopen, -- can be quickfix or termopen
|
||||
reload_workspace_from_cargo_toml = true,
|
||||
runnables = {
|
||||
use_telescope = true,
|
||||
},
|
||||
inlay_hints = {
|
||||
auto = true,
|
||||
only_current_line = false,
|
||||
show_parameter_hints = false,
|
||||
parameter_hints_prefix = "<-",
|
||||
other_hints_prefix = "=>",
|
||||
max_len_align = false,
|
||||
max_len_align_padding = 1,
|
||||
right_align = false,
|
||||
right_align_padding = 7,
|
||||
highlight = "Comment",
|
||||
},
|
||||
hover_actions = {
|
||||
border = "rounded",
|
||||
},
|
||||
on_initialized = function()
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost", "BufEnter", "CursorHold", "InsertLeave" }, {
|
||||
pattern = { "*.rs" },
|
||||
callback = function()
|
||||
local _, _ = pcall(vim.lsp.codelens.refresh)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
dap = {
|
||||
-- adapter= codelldb_adapter,
|
||||
adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path),
|
||||
},
|
||||
server = {
|
||||
on_attach = function(client, bufnr)
|
||||
require("lvim.lsp").common_on_attach(client, bufnr)
|
||||
local rt = require "rust-tools"
|
||||
vim.keymap.set("n", "K", rt.hover_actions.hover_actions, { buffer = bufnr })
|
||||
end,
|
||||
|
||||
capabilities = require("lvim.lsp").common_capabilities(),
|
||||
settings = {
|
||||
["rust-analyzer"] = {
|
||||
lens = {
|
||||
enable = true,
|
||||
},
|
||||
checkOnSave = {
|
||||
enable = true,
|
||||
command = "clippy",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
})
|
||||
end)
|
||||
|
||||
-- Themes
|
||||
require('onedark').setup {
|
||||
style = 'darker', -- Default theme style. Choose between 'dark', 'darker', 'cool', 'deep', 'warm', 'warmer' and 'light'
|
||||
toggle_style_key = "<leader>ss",
|
||||
transparent = false, -- Show/hide background
|
||||
lvim.builtin.dap.on_config_done = function(dap)
|
||||
dap.adapters.codelldb = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path)
|
||||
dap.configurations.rust = {
|
||||
{
|
||||
name = "Launch file",
|
||||
type = "codelldb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file")
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopOnEntry = false,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
code_style = {
|
||||
comments = 'italic',
|
||||
keywords = 'italic,',
|
||||
functions = 'bold',
|
||||
strings = 'none',
|
||||
variables = 'none'
|
||||
vim.api.nvim_set_keymap("n", "<m-d>", "<cmd>RustOpenExternalDocs<Cr>", { noremap = true, silent = true })
|
||||
|
||||
lvim.builtin.which_key.mappings["C"] = {
|
||||
name = "Rust",
|
||||
r = { "<cmd>RustRunnables<Cr>", "Runnables" },
|
||||
t = { "<cmd>lua _CARGO_TEST()<cr>", "Cargo Test" },
|
||||
m = { "<cmd>RustExpandMacro<Cr>", "Expand Macro" },
|
||||
c = { "<cmd>RustOpenCargo<Cr>", "Open Cargo" },
|
||||
p = { "<cmd>RustParentModule<Cr>", "Parent Module" },
|
||||
d = { "<cmd>RustDebuggables<Cr>", "Debuggables" },
|
||||
v = { "<cmd>RustViewCrateGraph<Cr>", "View Crate Graph" },
|
||||
R = {
|
||||
"<cmd>lua require('rust-tools/workspace_refresh')._reload_workspace_from_cargo_toml()<Cr>",
|
||||
"Reload Workspace",
|
||||
},
|
||||
o = { "<cmd>RustOpenExternalDocs<Cr>", "Open External Docs" },
|
||||
y = { "<cmd>lua require'crates'.open_repository()<cr>", "[crates] open repository" },
|
||||
P = { "<cmd>lua require'crates'.show_popup()<cr>", "[crates] show popup" },
|
||||
i = { "<cmd>lua require'crates'.show_crate_popup()<cr>", "[crates] show info" },
|
||||
f = { "<cmd>lua require'crates'.show_features_popup()<cr>", "[crates] show features" },
|
||||
D = { "<cmd>lua require'crates'.show_dependencies_popup()<cr>", "[crates] show dependencies" },
|
||||
}
|
||||
--
|
||||
|
||||
|
||||
-- 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,
|
||||
-- })
|
||||
|
||||
Reference in New Issue
Block a user