diff --git a/.config/nvim/lua/user/cmp.lua b/.config/nvim/lua/user/cmp.lua index 300740a..1625894 100644 --- a/.config/nvim/lua/user/cmp.lua +++ b/.config/nvim/lua/user/cmp.lua @@ -62,7 +62,7 @@ cmp.setup { }, -- Accept currently selected item. If none selected, `select` first item. -- Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm { select = true }, + [""] = cmp.mapping.confirm { select = false }, [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() diff --git a/.config/nvim/lua/user/keymaps.lua b/.config/nvim/lua/user/keymaps.lua index 049c011..375f303 100644 --- a/.config/nvim/lua/user/keymaps.lua +++ b/.config/nvim/lua/user/keymaps.lua @@ -39,6 +39,7 @@ keymap("n", "g#", "g#zz", opts) keymap("n", "", "zz", opts) keymap("n", "", "zz", opts) +-- Allow moving selected text keymap("x", "J", ":move '>+1gv-gv", opts) keymap("x", "K", ":move '<-2gv-gv", opts) keymap("x", "", ":move '>+1gv-gv", opts) @@ -48,5 +49,8 @@ keymap("x", "", ":move '<-2gv-gv", opts) keymap("n", "", ":tabnext", opts) keymap("n", "", ":tabprevious", opts) +-- Copy to clipboard +keymap("v", "", "\"+y", opts) + --Close buffer -- keymap("n", "", ":bd | bp ", opts) diff --git a/.config/nvim/lua/user/lsp/handlers.lua b/.config/nvim/lua/user/lsp/diagnostics_config.lua similarity index 61% rename from .config/nvim/lua/user/lsp/handlers.lua rename to .config/nvim/lua/user/lsp/diagnostics_config.lua index 7831c54..93e22e9 100644 --- a/.config/nvim/lua/user/lsp/handlers.lua +++ b/.config/nvim/lua/user/lsp/diagnostics_config.lua @@ -27,17 +27,4 @@ M.setup = function() vim.diagnostic.config(config) end --- local function lsp_highlight_document(client) --- -- Set autocommands conditional on server_capabilities --- local status_ok, illuminate = pcall(require, "illuminate") --- if not status_ok then --- return --- end --- illuminate.on_attach(client) --- end - --- M.on_attach = function(client, bufnr) --- lsp_highlight_document(client) --- end - return M diff --git a/.config/nvim/lua/user/lsp/init.lua b/.config/nvim/lua/user/lsp/init.lua index 050c086..8d74821 100644 --- a/.config/nvim/lua/user/lsp/init.lua +++ b/.config/nvim/lua/user/lsp/init.lua @@ -3,21 +3,10 @@ if not status_ok then return end -local status_ok, mason_lspconfig = pcall(require, "mason-lspconfig") -if not status_ok then - return -end - -local status_ok, lspconfig = pcall(require, "lspconfig") -if not status_ok then - return -end - mason.setup() -mason_lspconfig.setup() - -vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]]) require("user.lsp.mason_lsp_config") +require("user.lsp.diagnostics_config").setup() +-- require("user.none_ls") -- TODO: For now only uses python isort, uncomment when new stuff will be used -require("user.lsp.handlers").setup() +vim.cmd([[ command! Format execute 'lua vim.lsp.buf.format{async=true}' ]]) diff --git a/.config/nvim/lua/user/lsp/mason_lsp_config.lua b/.config/nvim/lua/user/lsp/mason_lsp_config.lua index 2b73bfc..5cc286b 100644 --- a/.config/nvim/lua/user/lsp/mason_lsp_config.lua +++ b/.config/nvim/lua/user/lsp/mason_lsp_config.lua @@ -1,65 +1,48 @@ local mason_lspconfig = require("mason-lspconfig") -local navic = require("nvim-navic") - -mason_lspconfig.setup_handlers({ - -- The first entry (without a key) will be the default handler - -- and will be called for each installed server that doesn't have - -- a dedicated handler. - ["omnisharp"] = function() - require("lspconfig")["omnisharp"].setup({ - on_attach = function(client, bufnr) - if client.name == "omnisharp" then - client.server_capabilities.semanticTokensProvider = nil - navic.attach(client, bufnr) - end - end, - }) - end, - ["pylsp"] = function() - require("lspconfig")["pylsp"].setup({ - on_attach = function(client, bufnr) - navic.attach(client, bufnr) - end, - settings = { - pylsp = { - plugins = { - pycodestyle = { - ignore = { "E501", "E231", "W503" }, - maxLineLength = 100, - }, - }, - }, - }, - }) - end, - ["rust_analyzer"] = function() - require("lspconfig")["rust_analyzer"].setup({ - on_attach = function(client, bufnr) - navic.attach(client, bufnr) - end, - settings = { - ["rust-analyzer"] = { - cargo = { - allFeatures = true, - }, - }, - }, - }) - end, - function(server_name) -- default handler (optional) - require("lspconfig")[server_name].setup({ - on_attach = function(client, bufnr) - navic.attach(client, bufnr) - end, - }) - end, - -- ["omnisharp"] = function() - -- require("omnisharp").setup({}) - -- end, - -- Next, you can provide a dedicated handler for specific servers. - -- For example, a handler override for the `rust_analyzer`: - -- ["rust_analyzer"] = function() - -- require("rust-tools").setup({}) - -- end, +vim.lsp.enable({ + "omnisharp", + "pylsp", + "rust_analyzer", }) + +-- TODO: this does not work, need to install pylsp-mypy plugin manually +local function extra_args() + local virtual = os.getenv("VIRTUAL_ENV") or "/usr" + return { "--python-executable", virtual .. "/bin/python3", true } +end + +vim.lsp.config('pylsp', { + settings = { + ["pylsp"] = { + enabled = true, + plugins = { + pycodestyle = { + ignore = { "E501", "E231", "W503" }, + maxLineLength = 100, + }, + pyls_isort = { enabled = true }, + pylsp_mypy = { + enabled = true, + -- this will make mypy to use the virtual environment + -- if not activated then it will use the system python(more specifically /usr/bin/python3) + overrides = extra_args(), + report_progress = true, + live_mode = true, + }, + }, + } + } +}) + +vim.lsp.config('rust_analyzer', { + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + }, + }, + } +}) + +mason_lspconfig.setup() diff --git a/.config/nvim/lua/user/lsp/settings/jsonls.lua b/.config/nvim/lua/user/lsp/settings/jsonls.lua deleted file mode 100644 index 8ee9544..0000000 --- a/.config/nvim/lua/user/lsp/settings/jsonls.lua +++ /dev/null @@ -1,182 +0,0 @@ -local schemas = { - { - description = "TypeScript compiler configuration file", - fileMatch = { - "tsconfig.json", - "tsconfig.*.json", - }, - url = "https://json.schemastore.org/tsconfig.json", - }, - { - description = "Lerna config", - fileMatch = { "lerna.json" }, - url = "https://json.schemastore.org/lerna.json", - }, - { - description = "Babel configuration", - fileMatch = { - ".babelrc.json", - ".babelrc", - "babel.config.json", - }, - url = "https://json.schemastore.org/babelrc.json", - }, - { - description = "ESLint config", - fileMatch = { - ".eslintrc.json", - ".eslintrc", - }, - url = "https://json.schemastore.org/eslintrc.json", - }, - { - description = "Bucklescript config", - fileMatch = { "bsconfig.json" }, - url = "https://raw.githubusercontent.com/rescript-lang/rescript-compiler/8.2.0/docs/docson/build-schema.json", - }, - { - description = "Prettier config", - fileMatch = { - ".prettierrc", - ".prettierrc.json", - "prettier.config.json", - }, - url = "https://json.schemastore.org/prettierrc", - }, - { - description = "Vercel Now config", - fileMatch = { "now.json" }, - url = "https://json.schemastore.org/now", - }, - { - description = "Stylelint config", - fileMatch = { - ".stylelintrc", - ".stylelintrc.json", - "stylelint.config.json", - }, - url = "https://json.schemastore.org/stylelintrc", - }, - { - description = "A JSON schema for the ASP.NET LaunchSettings.json files", - fileMatch = { "launchsettings.json" }, - url = "https://json.schemastore.org/launchsettings.json", - }, - { - description = "Schema for CMake Presets", - fileMatch = { - "CMakePresets.json", - "CMakeUserPresets.json", - }, - url = "https://raw.githubusercontent.com/Kitware/CMake/master/Help/manual/presets/schema.json", - }, - { - description = "Configuration file as an alternative for configuring your repository in the settings page.", - fileMatch = { - ".codeclimate.json", - }, - url = "https://json.schemastore.org/codeclimate.json", - }, - { - description = "LLVM compilation database", - fileMatch = { - "compile_commands.json", - }, - url = "https://json.schemastore.org/compile-commands.json", - }, - { - description = "Config file for Command Task Runner", - fileMatch = { - "commands.json", - }, - url = "https://json.schemastore.org/commands.json", - }, - { - description = "AWS CloudFormation provides a common language for you to describe and provision all the infrastructure resources in your cloud environment.", - fileMatch = { - "*.cf.json", - "cloudformation.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/cloudformation.schema.json", - }, - { - description = "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.", - fileMatch = { - "serverless.template", - "*.sam.json", - "sam.json", - }, - url = "https://raw.githubusercontent.com/awslabs/goformation/v5.2.9/schema/sam.schema.json", - }, - { - description = "Json schema for properties json file for a GitHub Workflow template", - fileMatch = { - ".github/workflow-templates/**.properties.json", - }, - url = "https://json.schemastore.org/github-workflow-template-properties.json", - }, - { - description = "golangci-lint configuration file", - fileMatch = { - ".golangci.toml", - ".golangci.json", - }, - url = "https://json.schemastore.org/golangci-lint.json", - }, - { - description = "JSON schema for the JSON Feed format", - fileMatch = { - "feed.json", - }, - url = "https://json.schemastore.org/feed.json", - versions = { - ["1"] = "https://json.schemastore.org/feed-1.json", - ["1.1"] = "https://json.schemastore.org/feed.json", - }, - }, - { - description = "Packer template JSON configuration", - fileMatch = { - "packer.json", - }, - url = "https://json.schemastore.org/packer.json", - }, - { - description = "NPM configuration file", - fileMatch = { - "package.json", - }, - url = "https://json.schemastore.org/package.json", - }, - { - description = "JSON schema for Visual Studio component configuration files", - fileMatch = { - "*.vsconfig", - }, - url = "https://json.schemastore.org/vsconfig.json", - }, - { - description = "Resume json", - fileMatch = { "resume.json" }, - url = "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json", - }, -} - -local opts = { - settings = { - json = { - schemas = schemas, - }, - }, - setup = { - commands = { - Format = { - function() - vim.lsp.buf.range_formatting({}, { 0, 0 }, { vim.fn.line "$", 0 }) - end, - }, - }, - }, -} - -return opts diff --git a/.config/nvim/lua/user/lsp/settings/lua_ls.lua b/.config/nvim/lua/user/lsp/settings/lua_ls.lua deleted file mode 100644 index 0ac454a..0000000 --- a/.config/nvim/lua/user/lsp/settings/lua_ls.lua +++ /dev/null @@ -1,16 +0,0 @@ -return { - settings = { - - Lua = { - diagnostics = { - globals = { "vim" }, - }, - workspace = { - library = { - [vim.fn.expand("$VIMRUNTIME/lua")] = true, - [vim.fn.stdpath("config") .. "/lua"] = true, - }, - }, - }, - }, -} diff --git a/.config/nvim/lua/user/lsp/settings/omnisharp.lua b/.config/nvim/lua/user/lsp/settings/omnisharp.lua deleted file mode 100644 index e69de29..0000000 diff --git a/.config/nvim/lua/user/lsp/settings/pyright.lua b/.config/nvim/lua/user/lsp/settings/pyright.lua deleted file mode 100644 index 49223b0..0000000 --- a/.config/nvim/lua/user/lsp/settings/pyright.lua +++ /dev/null @@ -1,12 +0,0 @@ -return { - settings = { - - python = { - analysis = { - typeCheckingMode = "off", - diagnosticMode = "workspace", - autoSearchPaths = true, - }, - }, - }, -} diff --git a/.config/nvim/lua/user/none_ls.lua b/.config/nvim/lua/user/none_ls.lua index 78c0b23..b539743 100644 --- a/.config/nvim/lua/user/none_ls.lua +++ b/.config/nvim/lua/user/none_ls.lua @@ -6,13 +6,20 @@ end local formatting = null_ls.builtins.formatting local diagnostics = null_ls.builtins.diagnostics +null_ls.builtins.diagnostics.mypy.with({ + extra_args = function() + local virtual = os.getenv("VIRTUAL_ENV") or "/usr" + return { "--python-executable", virtual .. "/bin/python3" } + end, +}) + null_ls.setup({ debug = false, sources = { - formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), - formatting.black.with({ extra_args = { "--fast" } }), + -- formatting.prettier.with({ extra_args = { "--no-semi", "--single-quote", "--jsx-single-quote" } }), + -- formatting.black.with({ extra_args = { "--fast" } }), formatting.isort, formatting.stylua, - -- diagnostics.flake8 + -- diagnostics.mypy, }, }) diff --git a/.config/nvim/lua/user/nvim_navic.lua b/.config/nvim/lua/user/nvim_navic.lua index ca609c2..1a3d002 100644 --- a/.config/nvim/lua/user/nvim_navic.lua +++ b/.config/nvim/lua/user/nvim_navic.lua @@ -5,7 +5,8 @@ end nvim_navic.setup({ lsp = { - auto_attach = true + auto_attach = true, + preference = {"pyright", "pylsp"} } }) diff --git a/.config/nvim/lua/user/colorschemes/tokyo_night.lua b/.config/nvim/lua/user/themes/tokyo_night.lua similarity index 100% rename from .config/nvim/lua/user/colorschemes/tokyo_night.lua rename to .config/nvim/lua/user/themes/tokyo_night.lua