274 lines
7.8 KiB
Lua
274 lines
7.8 KiB
Lua
--[[
|
||
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.log.level = "warn"
|
||
lvim.format_on_save = false
|
||
lvim.colorscheme = "onedark"
|
||
vim.opt.tabstop = 4
|
||
vim.opt.softtabstop = 4
|
||
vim.opt.shiftwidth = 4
|
||
|
||
-- 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>"
|
||
|
||
-- Use which-key to add extra bindings with the leader-key prefix
|
||
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"}
|
||
lvim.builtin.which_key.mappings["t"] = {
|
||
name = "+Terminal",
|
||
r = { "<cmd>ToggleTerm<cr>", "Floating terminal" },
|
||
y = { "<cmd>ToggleTerm size=60 direction=vertical<cr>", "Split vertical" },
|
||
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
|
||
lvim.plugins = {
|
||
{ "navarasu/onedark.nvim" },
|
||
{ "folke/tokyonight.nvim" },
|
||
{
|
||
"folke/trouble.nvim",
|
||
cmd = "TroubleToggle",
|
||
},
|
||
{
|
||
"Pocco81/auto-save.nvim",
|
||
config = function()
|
||
require("auto-save").setup()
|
||
end,
|
||
},
|
||
{'kevinhwang91/nvim-ufo'},
|
||
{'kevinhwang91/promise-async'},
|
||
-- Markdonw
|
||
{
|
||
"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'
|
||
},
|
||
-- Deno
|
||
{'sigmasd/deno-nvim'}
|
||
}
|
||
-- 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
|
||
vim.o.foldlevelstart = 99
|
||
vim.o.foldenable = true
|
||
vim.opt.fillchars = {
|
||
vert = "▕", -- alternatives │
|
||
fold = " ",
|
||
eob = " ", -- suppress ~ at EndOfBuffer
|
||
diff = "╱", -- alternatives = ⣿ ░ ─
|
||
msgsep = "‾",
|
||
foldopen = "",
|
||
foldsep = "│",
|
||
foldclose = "",
|
||
}
|
||
local fcs = vim.opt.fillchars:get()
|
||
|
||
-- Stolen from Akinsho
|
||
local function get_fold(lnum)
|
||
if vim.fn.foldlevel(lnum) <= vim.fn.foldlevel(lnum - 1)
|
||
then return ' '
|
||
end
|
||
local fold_sym =
|
||
vim.fn.foldclosed(lnum) == -1 and fcs.foldopen or fcs.foldclose
|
||
return fold_sym
|
||
end
|
||
_G.get_statuscol = function() return "%s%l " .. get_fold(vim.v.lnum) .. " " end
|
||
vim.o.statuscolumn = "%!v:lua.get_statuscol()"
|
||
|
||
|
||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||
capabilities.textDocument.foldingRange = {
|
||
dynamicRegistration = false,
|
||
lineFoldingOnly = true
|
||
}
|
||
local language_servers = require("lspconfig").util.available_servers() -- or list servers manually like {'gopls', 'clangd'}
|
||
for _, ls in ipairs(language_servers) do
|
||
require('lspconfig')[ls].setup({
|
||
capabilities = capabilities
|
||
-- you can add other fields for setting up lsp server in this table
|
||
})
|
||
end
|
||
require('ufo').setup()
|
||
|
||
-- Java
|
||
local lspconfig = require('lspconfig')
|
||
local lombok = vim.fn.stdpath('data') .. '/mason/packages/jdtls/lombok.jar'
|
||
lspconfig.jdtls.setup { cmd = { "jdtls", "--jvm-arg=-javaagent:" .. lombok } }
|
||
|
||
-- 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
|
||
}
|
||
|
||
require("deno-nvim").setup({
|
||
server = {
|
||
on_attach = ...,
|
||
capabilites = ...
|
||
},
|
||
-- if you're using dap to debug (see the README for more info)
|
||
dap = {
|
||
adapter = ...
|
||
}
|
||
})
|
||
|
||
-- 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'
|
||
},
|
||
}
|
||
--
|
||
|
||
|
||
-- 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,
|
||
-- })
|