Add lvim config and nvim

This commit is contained in:
Smirnov-O 2021-09-11 15:59:44 +03:00
parent 0b1ace53f2
commit d1af9278c5
19 changed files with 303 additions and 26 deletions

42
config/lvim/config.lua Normal file
View file

@ -0,0 +1,42 @@
lvim.leader = "space"
lvim.format_on_save = false
lvim.lint_on_save = false
lvim.colorscheme = "onedarker"
-- Terminal
lvim.builtin.terminal.active = true
lvim.builtin.autopairs.active = true
-- GitSigns
lvim.builtin.gitsigns.opts.current_line_blame = true
lvim.builtin.gitsigns.opts.current_line_blame_opts = { virt_text = true, virt_text_pos = "eol", delay = 200 }
-- TreeSitter
lvim.builtin.treesitter.ensure_installed = { "javascript", "typescript", "jsdoc", "lua", "java" }
lvim.builtin.treesitter.indent.disable = { "clojure", "java", "python" }
-- Telescope
lvim.builtin.telescope.defaults.layout_config.prompt_position = "top"
lvim.builtin.telescope.defaults.file_ignore_patterns = { ".git", "node_modules", "env" }
-- Mappings
lvim.keys.normal_mode["<C-w>"] = "<cmd>BufferClose<cr>"
lvim.keys.normal_mode["<C-s>"] = "<cmd>w<cr>"
lvim.builtin.which_key.mappings.l.d = { "<cmd>TroubleToggle<cr>", "Diagnostics" }
lvim.builtin.which_key.mappings.l.R = { "<cmd>TroubleToggle lsp_references<cr>", "References" }
local fmt = string.format
for i = 1, 9 do
lvim.keys.normal_mode[fmt("<A-%d>", i)] = fmt("<cmd>BufferGoto %d<cr>", i)
end
-- Plugins
lvim.plugins = {
{ "tpope/vim-surround", keys = { "c", "y", "d" } },
{ "andymass/vim-matchup", keys = { "%" } },
{ "tzachar/cmp-tabnine", run = "./install.sh", event = "InsertEnter" },
{ "folke/trouble.nvim", cmd = { "TroubleToggle" } },
{ "folke/todo-comments.nvim", event = "BufRead" },
{ "mfussenegger/nvim-jdtls", ft = { "java" } },
{ "npxbr/glow.nvim", ft = { "markdown" }, cmd = { "Glow" } },
}

View file

@ -0,0 +1,5 @@
lvim.format_on_save = true
lvim.lang.go.formatters = {
{ exe = "gofmt" },
{ exe = "goimports" },
}

View file

@ -0,0 +1,22 @@
if vim.fn.has("mac") == 1 then
WORKSPACE_PATH = "/Users/" .. USER .. "/workspace/"
elseif vim.fn.has("unix") == 1 then
WORKSPACE_PATH = "/home/" .. USER .. "/workspace/"
else
print("Unsupported system")
end
JAVA_LS_EXECUTABLE = os.getenv("HOME") .. "/.local/share/lunarvim/lvim/utils/bin/jdtls"
require("jdtls").start_or_attach({
on_attach = require("lsp").common_on_attach,
cmd = { JAVA_LS_EXECUTABLE, WORKSPACE_PATH .. vim.fn.fnamemodify(vim.fn.getcwd(), ":p:h:t") },
})
vim.api.nvim_set_keymap("n", "<leader>la", ":lua require('jdtls').code_action()<CR>", { noremap = true, silent = true })
vim.cmd("command! -buffer JdtCompile lua require('jdtls').compile()")
vim.cmd("command! -buffer JdtUpdateConfig lua require('jdtls').update_project_config()")
vim.cmd("command! -buffer JdtJol lua require('jdtls').jol()")
vim.cmd("command! -buffer JdtBytecode lua require('jdtls').javap()")
vim.cmd("command! -buffer JdtJshell lua require('jdtls').jshell()")

View file

@ -0,0 +1,24 @@
lvim.lang.javascript.formatters = {
-- { exe = "eslint_d" },
{ exe = "prettierd" },
}
lvim.lang.javascript.linters = {
{ exe = "eslint_d" },
}
lvim.lang.javascript.lsp.setup.handlers = {
["textDocument/publishDiagnostics"] = function(_, _, p, client_id, _, config)
if p.diagnostics ~= nil then
local i = 1
while i <= #p.diagnostics do
if p.diagnostics[i].code == 80001 then
table.remove(p.diagnostics, i)
else
i = i + 1
end
end
end
vim.lsp.diagnostic.on_publish_diagnostics(_, _, p, client_id, _, config)
end,
}

View file

@ -0,0 +1,9 @@
lvim.format_on_save = true
lvim.lang.lua.formatters = {
{ exe = "stylua" },
}
lvim.lang.lua.linters = {
-- { exe = "luacheck" },
-- { exe = "selene" },
}

View file

@ -0,0 +1,9 @@
lvim.format_on_save = true
lvim.lang.python.formatters = {
{ exe = "black" },
{ exe = "isort" },
}
lvim.lang.python.linters = {
{ exe = "flake8" },
}

View file

@ -0,0 +1,8 @@
lvim.lang.typescript.formatters = {
-- { exe = "eslint_d" },
{ exe = "prettierd" },
}
lvim.lang.typescript.linters = {
{ exe = "eslint_d" },
}

View file

@ -0,0 +1,3 @@
{
"java.format.enabled": true
}

View file

@ -0,0 +1,77 @@
{
"json.schemas": [
{
"fileMatch": [
"package.json"
],
"url": "https://json.schemastore.org/package.json"
},
{
"fileMatch": [
"tsconfig.json",
"tsconfig.*.json"
],
"url": "http://json.schemastore.org/tsconfig"
},
{
"fileMatch": [
"lerna.json"
],
"url": "http://json.schemastore.org/lerna"
},
{
"fileMatch": [
".babelrc.json",
".babelrc",
"babel.config.json"
],
"url": "http://json.schemastore.org/lerna"
},
{
"fileMatch": [
".eslintrc.json",
".eslintrc"
],
"url": "http://json.schemastore.org/eslintrc"
},
{
"fileMatch": [
"bsconfig.json"
],
"url": "https://bucklescript.github.io/bucklescript/docson/build-schema.json"
},
{
"fileMatch": [
".prettierrc",
".prettierrc.json",
"prettier.config.json"
],
"url": "http://json.schemastore.org/prettierrc"
},
{
"fileMatch": [
"now.json"
],
"url": "http://json.schemastore.org/now"
},
{
"fileMatch": [
"openapi.json",
"swagger.json"
],
"url": "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json"
},
{
"fileMatch": [
"nest-cli.json"
],
"url": "https://json.schemastore.org/nest-cli.json"
},
{
"fileMatch": [
"nodemon.json"
],
"url": "https://json.schemastore.org/nodemon.json"
}
]
}

View file

@ -0,0 +1,3 @@
{
"python.analysis.typeCheckingMode": "off"
}

View file

@ -0,0 +1,36 @@
{
"yaml.schemas": {
"https://raw.githubusercontent.com/compose-spec/compose-spec/master/schema/compose-spec.json": [
"docker-compose.yml",
"docker-compose.yaml"
],
"https://json.schemastore.org/ansible-playbook.json": [
"*/playbook/**/*.yml",
"*/playbooks/**/*.yml",
"*/playbook/**/*.yaml",
"*/playbooks/**/*.yaml"
],
"https://json.schemastore.org/yamllint.json": [
".yamllint",
".yamllint.yml",
".yamllint.yaml"
],
"https://yarnpkg.com/configuration/yarnrc.json": [
".yarnrc",
".yarnrc.yml"
],
"https://json.schemastore.org/github-action.json": [
"*/.github/workflows/**/*.yml",
"*/.github/workflows/**/*.yaml"
],
"https://json.schemastore.org/gitlab-ci.json": [
".gitlab-ci.yml"
],
"https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.1/schema.json": [
"openapi.yaml",
"openapi.yml",
"swagger.yml",
"swagger.yal"
]
}
}

View file

@ -0,0 +1,7 @@
local M = {}
M.config = function ()
vim.cmd [[ let maplocalleader = "," ]]
end
return M

View file

@ -0,0 +1,14 @@
local M = {}
M.config = function()
require("package-info").setup({{
autostart = true,
colors = { up_to_date = "#3C4048", outdated = "#6ec0fa" },
icons = {
enable = true,
style = { up_to_date = "|  ", outdated = "|  " },
},
}})
end
return M

@ -0,0 +1 @@
Subproject commit 148c430da4e02dab923ec86c10baf0d7bcb976ee

18
config/nvim/init.lua Normal file
View file

@ -0,0 +1,18 @@
local pack_path = vim.fn.stdpath("data") .. "/site/pack"
local fmt = string.format
local function ensure(user, repo)
local install_path = fmt("%s/packer/start/%s", pack_path, repo, repo)
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
vim.api.nvim_command(fmt("!git clone https://github.com/%s/%s %s", user, repo, install_path))
vim.api.nvim_command(fmt("packadd %s", repo))
end
end
ensure("wbthomason", "packer.nvim")
ensure("Olical", "aniseed")
vim.g["aniseed#env"] = {
module = "config.init",
compile = true,
}

View file

@ -1,4 +1,4 @@
rofi.theme: nten-light
rofi.theme: nten
rofi.font: Jetbarains Mono 12
rofi.auto-select: false
rofi.hide-scrollbar: true

View file

@ -1,6 +1,6 @@
#!/usr/bin/env bash
declare options=("ShutDown\nLogOut\nReboot")
rofitheme="nten-light-dmenu"
rofitheme="nten-dmenu"
choice=$(echo -e ${options[@]} | rofi -dmenu -p "Power" -theme $rofitheme)
case $choice in