From d1af9278c54f590380d35727fc4577dac262bc60 Mon Sep 17 00:00:00 2001 From: Smirnov-O Date: Sat, 11 Sep 2021 15:59:44 +0300 Subject: [PATCH] Add lvim config and nvim --- config/lvim/config.lua | 42 +++++++++++++++ config/lvim/ftplugin/go.lua | 5 ++ config/lvim/ftplugin/java.lua | 22 ++++++++ config/lvim/ftplugin/javascript.lua | 24 +++++++++ config/lvim/ftplugin/lua.lua | 9 ++++ config/lvim/ftplugin/python.lua | 9 ++++ config/lvim/ftplugin/typescript.lua | 8 +++ config/lvim/lsp-settings/jdtls.json | 3 ++ config/lvim/lsp-settings/jsonls.json | 77 +++++++++++++++++++++++++++ config/lvim/lsp-settings/pyright.json | 3 ++ config/lvim/lsp-settings/yamlls.json | 36 +++++++++++++ config/lvim/lua/u/conjure.lua | 7 +++ config/lvim/lua/u/package-info.lua | 14 +++++ config/nvim/fnl/config | 1 + config/nvim/init.lua | 18 +++++++ config/rofi/config | 2 +- config/rofi/script/powermenu.sh | 2 +- vscode/settings.json | 42 +++++++-------- zshrc | 5 ++ 19 files changed, 303 insertions(+), 26 deletions(-) create mode 100644 config/lvim/config.lua create mode 100644 config/lvim/ftplugin/go.lua create mode 100644 config/lvim/ftplugin/java.lua create mode 100644 config/lvim/ftplugin/javascript.lua create mode 100644 config/lvim/ftplugin/lua.lua create mode 100644 config/lvim/ftplugin/python.lua create mode 100644 config/lvim/ftplugin/typescript.lua create mode 100644 config/lvim/lsp-settings/jdtls.json create mode 100644 config/lvim/lsp-settings/jsonls.json create mode 100644 config/lvim/lsp-settings/pyright.json create mode 100644 config/lvim/lsp-settings/yamlls.json create mode 100644 config/lvim/lua/u/conjure.lua create mode 100644 config/lvim/lua/u/package-info.lua create mode 160000 config/nvim/fnl/config create mode 100644 config/nvim/init.lua diff --git a/config/lvim/config.lua b/config/lvim/config.lua new file mode 100644 index 0000000..45f59b5 --- /dev/null +++ b/config/lvim/config.lua @@ -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[""] = "BufferClose" +lvim.keys.normal_mode[""] = "w" +lvim.builtin.which_key.mappings.l.d = { "TroubleToggle", "Diagnostics" } +lvim.builtin.which_key.mappings.l.R = { "TroubleToggle lsp_references", "References" } + +local fmt = string.format +for i = 1, 9 do + lvim.keys.normal_mode[fmt("", i)] = fmt("BufferGoto %d", 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" } }, +} diff --git a/config/lvim/ftplugin/go.lua b/config/lvim/ftplugin/go.lua new file mode 100644 index 0000000..89a0f53 --- /dev/null +++ b/config/lvim/ftplugin/go.lua @@ -0,0 +1,5 @@ +lvim.format_on_save = true +lvim.lang.go.formatters = { + { exe = "gofmt" }, + { exe = "goimports" }, +} diff --git a/config/lvim/ftplugin/java.lua b/config/lvim/ftplugin/java.lua new file mode 100644 index 0000000..6529eba --- /dev/null +++ b/config/lvim/ftplugin/java.lua @@ -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", "la", ":lua require('jdtls').code_action()", { 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()") diff --git a/config/lvim/ftplugin/javascript.lua b/config/lvim/ftplugin/javascript.lua new file mode 100644 index 0000000..9851433 --- /dev/null +++ b/config/lvim/ftplugin/javascript.lua @@ -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, +} diff --git a/config/lvim/ftplugin/lua.lua b/config/lvim/ftplugin/lua.lua new file mode 100644 index 0000000..9f74577 --- /dev/null +++ b/config/lvim/ftplugin/lua.lua @@ -0,0 +1,9 @@ +lvim.format_on_save = true +lvim.lang.lua.formatters = { + { exe = "stylua" }, +} + +lvim.lang.lua.linters = { + -- { exe = "luacheck" }, + -- { exe = "selene" }, +} diff --git a/config/lvim/ftplugin/python.lua b/config/lvim/ftplugin/python.lua new file mode 100644 index 0000000..44652be --- /dev/null +++ b/config/lvim/ftplugin/python.lua @@ -0,0 +1,9 @@ +lvim.format_on_save = true +lvim.lang.python.formatters = { + { exe = "black" }, + { exe = "isort" }, +} + +lvim.lang.python.linters = { + { exe = "flake8" }, +} diff --git a/config/lvim/ftplugin/typescript.lua b/config/lvim/ftplugin/typescript.lua new file mode 100644 index 0000000..e1def86 --- /dev/null +++ b/config/lvim/ftplugin/typescript.lua @@ -0,0 +1,8 @@ +lvim.lang.typescript.formatters = { + -- { exe = "eslint_d" }, + { exe = "prettierd" }, +} + +lvim.lang.typescript.linters = { + { exe = "eslint_d" }, +} diff --git a/config/lvim/lsp-settings/jdtls.json b/config/lvim/lsp-settings/jdtls.json new file mode 100644 index 0000000..a9132f7 --- /dev/null +++ b/config/lvim/lsp-settings/jdtls.json @@ -0,0 +1,3 @@ +{ + "java.format.enabled": true +} diff --git a/config/lvim/lsp-settings/jsonls.json b/config/lvim/lsp-settings/jsonls.json new file mode 100644 index 0000000..8f2fcae --- /dev/null +++ b/config/lvim/lsp-settings/jsonls.json @@ -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" + } + ] +} diff --git a/config/lvim/lsp-settings/pyright.json b/config/lvim/lsp-settings/pyright.json new file mode 100644 index 0000000..cc5a352 --- /dev/null +++ b/config/lvim/lsp-settings/pyright.json @@ -0,0 +1,3 @@ +{ + "python.analysis.typeCheckingMode": "off" +} diff --git a/config/lvim/lsp-settings/yamlls.json b/config/lvim/lsp-settings/yamlls.json new file mode 100644 index 0000000..e26fa2e --- /dev/null +++ b/config/lvim/lsp-settings/yamlls.json @@ -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" + ] + } +} diff --git a/config/lvim/lua/u/conjure.lua b/config/lvim/lua/u/conjure.lua new file mode 100644 index 0000000..bbc96bd --- /dev/null +++ b/config/lvim/lua/u/conjure.lua @@ -0,0 +1,7 @@ +local M = {} + +M.config = function () + vim.cmd [[ let maplocalleader = "," ]] +end + +return M diff --git a/config/lvim/lua/u/package-info.lua b/config/lvim/lua/u/package-info.lua new file mode 100644 index 0000000..7cb4622 --- /dev/null +++ b/config/lvim/lua/u/package-info.lua @@ -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 diff --git a/config/nvim/fnl/config b/config/nvim/fnl/config new file mode 160000 index 0000000..148c430 --- /dev/null +++ b/config/nvim/fnl/config @@ -0,0 +1 @@ +Subproject commit 148c430da4e02dab923ec86c10baf0d7bcb976ee diff --git a/config/nvim/init.lua b/config/nvim/init.lua new file mode 100644 index 0000000..9619c9e --- /dev/null +++ b/config/nvim/init.lua @@ -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, +} diff --git a/config/rofi/config b/config/rofi/config index e036185..35f0d24 100644 --- a/config/rofi/config +++ b/config/rofi/config @@ -1,4 +1,4 @@ -rofi.theme: nten-light +rofi.theme: nten rofi.font: Jetbarains Mono 12 rofi.auto-select: false rofi.hide-scrollbar: true diff --git a/config/rofi/script/powermenu.sh b/config/rofi/script/powermenu.sh index 3c8cf72..100db1d 100755 --- a/config/rofi/script/powermenu.sh +++ b/config/rofi/script/powermenu.sh @@ -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 diff --git a/vscode/settings.json b/vscode/settings.json index 6c954b7..5e0f632 100644 --- a/vscode/settings.json +++ b/vscode/settings.json @@ -1,11 +1,12 @@ { "workbench.iconTheme": "material-icon-theme", - "workbench.colorTheme": "GitHub Light", + "workbench.colorTheme": "GitHub Dark Default", "workbench.sideBar.location": "right", "workbench.editor.untitled.hint": "hidden", "workbench.startupEditor": "none", - "workbench.panel.defaultLocation": "left", + "workbench.panel.defaultLocation": "bottom", "workbench.activityBar.visible": false, + "window.menuBarVisibility": "toggle", "update.showReleaseNotes": false, // Editor // "editor.cursorSmoothCaretAnimation": true, @@ -23,7 +24,7 @@ "editor.fontSize": 14, "editor.tabSize": 4, // Files - "explorer.compactFolders": false, + "explorer.compactFolders": true, "explorer.confirmDragAndDrop": false, "explorer.confirmDelete": false, "files.insertFinalNewline": false, @@ -31,32 +32,27 @@ "files.trimTrailingWhitespace": false, "files.exclude": { "**/node_modules": true, - "**/env": true + "**/env": true, + "**/.classpath": true, + "**/.project": true, + "**/.settings": true, + "**/.factorypath": true }, // Git "gitlens.codeLens.enabled": true, "git.autofetch": true, "git.confirmSync": false, "git.enableSmartCommit": true, - // Vim - "vim.easymotion": true, - "vim.surround": true, - "vim.useSystemClipboard": true, - "vim.hlsearch": true, - "vim.incsearch": true, - "vim.leader": ";", - "vim.normalModeKeyBindings": [ - {"before": [""], "commands": [":nohl"]}, - ], - "vim.insertModeKeyBindings": [ - {"before": ["j", "k"], "after": [""]} - ], - "vim.handleKeys": { "": false, "": false, "": false, "": false}, - // Expensions "terminal.integrated.tabs.enabled": false, + // Extensions "extensions.ignoreRecommendations": true, "docker.showStartPage": false, - // "prettier.semi": false, + "calva.myCljAliases": [ + "nREPL", + "nrepl", + "test" + ], + "calva.paredit.defaultKeyMap": "strict", // Languages "javascript.suggestionActions.enabled": false, "typescript.suggestionActions.enabled": false, @@ -66,7 +62,5 @@ }, "[typescript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - }, - "window.menuBarVisibility": "toggle" - -} \ No newline at end of file + } +} diff --git a/zshrc b/zshrc index 1e0d117..6cd8ba0 100644 --- a/zshrc +++ b/zshrc @@ -17,6 +17,11 @@ source "$HOME/.oh-my-zsh/oh-my-zsh.sh" ## FNM eval $(fnm env) +## Functions +dotnet() { + $HOME/dotnet/dotnet "$@" +} + ## Aliases alias cls="clear" cp="cp -r" mkdir="mkdir -p" open="open_command" lg="lazygit" alias lv="lvim" vim="lvim"