diff --git a/lua/lsp/config/bashls.lua b/lua/lsp/config/bashls.lua index 325b829..4428457 100644 --- a/lua/lsp/config/bashls.lua +++ b/lua/lsp/config/bashls.lua @@ -1,3 +1,5 @@ +local utils = require("utils") + return { enable = true, dependencies = { @@ -7,6 +9,20 @@ return { name = "bash-language-server", dependencies = { { name = "shellcheck", }, + { name = "shfmt", }, + }, + }, + keymaps = { + { + mode = "n", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { "shfmt", "-s", "-i", "4", "-" }, + stdin = true, + stdout = true, + }) + end, }, }, lspconfig = { diff --git a/lua/lsp/config/diagnosticls.lua b/lua/lsp/config/diagnosticls.lua index 630e6d6..57f66b3 100644 --- a/lua/lsp/config/diagnosticls.lua +++ b/lua/lsp/config/diagnosticls.lua @@ -5,7 +5,7 @@ -- https://github.com/iamcco/coc-diagnostic/blob/master/src/config.ts return { - enable = true, + enable = false, dependencies = { "npm", }, diff --git a/lua/lsp/config/intelephense.lua b/lua/lsp/config/intelephense.lua index 0bcc294..16b672d 100644 --- a/lua/lsp/config/intelephense.lua +++ b/lua/lsp/config/intelephense.lua @@ -12,15 +12,12 @@ return { "composer.lock", "vendor", }, - mason = { - name = "intelephense", - -- version = "", - }, + mason = "intelephense", lspconfig = { filetypes = { "php", }, - cmd = { "intelephense", "--stdio", }, + cmd = { "intelephense", "--stdio" }, single_file_support = true, settings = { intelephense = { diff --git a/lua/lsp/config/jedi_language_server.lua b/lua/lsp/config/jedi_language_server.lua index e45d5f8..5f4653c 100644 --- a/lua/lsp/config/jedi_language_server.lua +++ b/lua/lsp/config/jedi_language_server.lua @@ -1,17 +1,89 @@ +local utils = require("utils") + +---@type ServerConfig return { enable = false, - dependencies = { - "python3", + dependencies = { "python3" }, + mason = { "jedi-language-server" }, + linters = { + { + cmd = { + "flake8", + "--max-line-length=100", + "--max-doc-length=100", + "--format", + "%(row)d,%(col)d,%(code).1s: %(text)s", + "-", + }, + stdin = true, + stdout = true, + pattern = "^(%d+),(%d+),(%w): (.*)", + groups = { "lnum", "col", "severity", "message" }, + source = "flake8", + severity_map = { + E = vim.diagnostic.severity.ERROR, + W = vim.diagnostic.severity.WARN, + B = vim.diagnostic.severity.HINT, + F = vim.diagnostic.severity.HINT, + D = vim.diagnostic.severity.INFO, + }, + }, }, - mason = { - name = "jedi-language-server", - -- version = "", + keymaps = { + { + mode = "n", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "black", + "--line-length", + "100", + "--stdin-filename", + "%filename%", + "--quiet", + "-", + }, + stdin = true, + stdout = true, + }) + utils.format({ + cmd = { + "isort", + "--quiet", + "-", + }, + stdin = true, + stdout = true, + }) + end, + }, + { + mode = "x", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "black", + "--line-length", + "100", + "--stdin-filename", + "%filename%", + "--quiet", + "--line-ranges=%row_start%-%row_end%", + "-", + }, + stdin = true, + stdout = true, + }) + end, + }, }, lspconfig = { filetypes = { "python", }, - cmd = { "jedi-language-server", }, + cmd = { "jedi-language-server" }, single_file_support = true, -- For more info see: -- - https://github.com/pappasam/jedi-language-server#configuration @@ -40,9 +112,18 @@ return { -- If you manually set this option, it overrides the default. -- Setting it to an empty array will result in no ignored folders. ignoreFolders = { - ".nox", ".tox", ".venv", "__pycache__", "venv", - "artifacts", "config", ".vscode", ".pytest_cache", - "build", "scripts", "incoax_tests.egg-info", + ".nox", + ".tox", + ".venv", + "__pycache__", + "venv", + "artifacts", + "config", + ".vscode", + ".pytest_cache", + "build", + "scripts", + "incoax_tests.egg-info", "node_modules", }, }, diff --git a/lua/lsp/config/lua_ls.lua b/lua/lsp/config/lua_ls.lua index b9b85c6..44d0a9a 100644 --- a/lua/lsp/config/lua_ls.lua +++ b/lua/lsp/config/lua_ls.lua @@ -1,39 +1,74 @@ -- spec: https://luals.github.io/wiki/settings/ +local utils = require("utils") ---@type ServerConfig return { enable = true, + dependencies = { "cargo" }, mason = { - name = "lua-language-server", - -- version = "", + "lua-language-server", + post_install = { { cmd = { "cargo", "install", "stylua", "--features", "lua54" } } }, + }, + keymaps = { + { + mode = "n", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { "stylua", "-" }, + stdin = true, + stdout = true, + }) + end, + }, + { + mode = "x", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "stylua", + "-", + "--range-start", + "%byte_start%", + "--range-end", + "%byte_end%", + }, + stdin = true, + stdout = true, + }) + end, + }, }, lspconfig = { - filetypes = { - "lua", - }, - cmd = { "lua-language-server", }, + filetypes = { "lua" }, + cmd = { "lua-language-server" }, single_file_support = true, settings = { Lua = { - completion = { - showWord = "Disable", - }, + completion = { showWord = "Disable" }, diagnostics = { - disable = { "missing-fields", }, + -- disable = { "missing-fields" }, }, runtime = { version = "LuaJIT", path = { - "lua/?.lua", - "lua/?/init.lua", - "?/lua/?.lua", - "?/lua/?/init.lua", + -- "?.lua", + "?.lua", + "?/init.lua", + -- "?.lua", + -- "lua/?.lua", + -- "lua/?/init.lua", + -- "?/lua/?.lua", + -- "?/lua/?/init.lua", }, + -- pathStrict = true, }, workspace = { library = { vim.env.VIMRUNTIME, - "/usr/share/lua/5.3", + "~/repos/awesome-code-doc", + "/usr/share/awesome/lib", vim.fn.stdpath("data") .. "/lazy", }, checkThirdParty = false, @@ -47,7 +82,7 @@ return { semicolon = "Disable", setType = true, }, - telemetry = { enable = false, }, + telemetry = { enable = false }, }, }, }, diff --git a/lua/lsp/config/pylsp.lua b/lua/lsp/config/pylsp.lua deleted file mode 100644 index 9ca6660..0000000 --- a/lua/lsp/config/pylsp.lua +++ /dev/null @@ -1,88 +0,0 @@ --- spec: https://github.com/python-lsp/python-lsp-server/blob/develop/CONFIGURATION.md - ---- @type ServerConfig -return { - enable = true, - dependencies = { - "python3", - }, - mason = { - name = "python-lsp-server", - post_install = { - { - command = "./venv/bin/pip", - -- command = "sh", - args = { - -- "install", - -- "python-lsp-black", - -- "python-lsp-isort", - "--version", - -- "-c", - -- "./venv/bin/pip --version", - }, - }, - -- { - -- command = "./venv/bin/pip", - -- args = { "alsdkfjhaklsdfjhl", }, - -- }, - }, - }, - lspconfig = { - filetypes = { - "python", - }, - cmd = { "pylsp", }, - single_file_support = true, - settings = { - pylsp = { - configurationSources = { "flake8", }, - plugins = { - autopep8 = { - enabled = false, - }, - black = { - enabled = true, - line_length = 100, - }, - flake8 = { - enabled = true, - exclude = { ".venv", "build/", }, - filename = { "*.py", }, - -- B - flake8-bugbear https://github.com/PyCQA/flake8-bugbear - -- C - only one violation, C901. mccabe https://github.com/PyCQA/mccabe - -- D - flake8-docstrings (pydocstyle) http://www.pydocstyle.org/en/stable/error_codes.html - -- E - pycodestyle https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes - -- F - flake8 https://flake8.pycqa.org/en/latest/user/error-codes.html - -- W - pycodestyle https://pycodestyle.pycqa.org/en/latest/intro.html#error-codes - select = { - "B", "B902", "B903", "B904", "C", "E", "F", "W", - }, - ignore = { - "B950", "D201", "D203", "D205", "D301", "D400", "E133", "E203", "W503", - }, - maxLineLength = 100, - maxDocLength = 100, - }, - isort = { - enabled = true, - }, - mccabe = { - enabled = false, - }, - pycodestyle = { - enabled = false, - }, - pydocstyle = { - enabled = false, - }, - pyflakes = { - enabled = false, - }, - yapf = { - enabled = false, - }, - }, - }, - }, - }, -} diff --git a/lua/lsp/config/pyright.lua b/lua/lsp/config/pyright.lua new file mode 100644 index 0000000..096a3fe --- /dev/null +++ b/lua/lsp/config/pyright.lua @@ -0,0 +1,95 @@ +local utils = require("utils") + +---@type ServerConfig +return { + enable = true, + mason = { "pyright" }, + linters = { + { + cmd = { + "flake8", + "--max-line-length=100", + "--max-doc-length=100", + "--format", + "%(row)d,%(col)d,%(code).1s: %(text)s", + "-", + }, + stdin = true, + stdout = true, + pattern = "^(%d+),(%d+),(%w): (.*)", + groups = { "lnum", "col", "severity", "message" }, + source = "flake8", + severity_map = { + E = vim.diagnostic.severity.ERROR, + W = vim.diagnostic.severity.WARN, + B = vim.diagnostic.severity.HINT, + F = vim.diagnostic.severity.HINT, + D = vim.diagnostic.severity.INFO, + }, + }, + }, + keymaps = { + { + mode = "n", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "black", + "--line-length", + "100", + "--stdin-filename", + "%filename%", + "--quiet", + "-", + }, + stdin = true, + stdout = true, + }) + utils.format({ + cmd = { + "isort", + "--quiet", + "-", + }, + stdin = true, + stdout = true, + }) + end, + }, + { + mode = "x", + lhs = "lf", + rhs = function() + utils.format({ + cmd = { + "black", + "--line-length", + "100", + "--stdin-filename", + "%filename%", + "--quiet", + "--line-ranges=%row_start%-%row_end%", + "-", + }, + stdin = true, + stdout = true, + }) + end, + }, + }, + lspconfig = { + filetypes = { "python" }, + cmd = { "pyright-langserver", "--stdio" }, + single_file_support = true, + settings = { + python = { + analysis = { + autoSearchPaths = true, + diagnosticMode = "openFilesOnly", + useLibraryCodeForTypes = true, + }, + }, + }, + }, +}