From e01b9b89013ccbf49bb2f3470ef827b771d2e559 Mon Sep 17 00:00:00 2001 From: Fabio Montefuscolo Date: Mon, 26 Feb 2024 15:54:13 +0100 Subject: [PATCH] initial config --- chadrc.lua | 8 ++++++++ configs/lspconfig.lua | 13 +++++++++++++ configs/null-ls.lua | 27 +++++++++++++++++++++++++++ mappings.lua | 14 ++++++++++++++ plugins.lua | 25 +++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 chadrc.lua create mode 100644 configs/lspconfig.lua create mode 100644 configs/null-ls.lua create mode 100644 mappings.lua create mode 100644 plugins.lua diff --git a/chadrc.lua b/chadrc.lua new file mode 100644 index 0000000..5f9455b --- /dev/null +++ b/chadrc.lua @@ -0,0 +1,8 @@ +---@type ChadrcConfig +local M = {} + +M.ui = { theme = 'chadracula' } +M.plugins = "custom.plugins" +M.mappings = require "custom.mappings" + +return M diff --git a/configs/lspconfig.lua b/configs/lspconfig.lua new file mode 100644 index 0000000..aea4805 --- /dev/null +++ b/configs/lspconfig.lua @@ -0,0 +1,13 @@ +local config = require("plugins.configs.lspconfig") + +local on_attach = config.on_attach +local capabilities = config.capabilities + +local lspconfig = require("lspconfig") + +lspconfig.pyright.setup({ + on_attach = on_attach, + capabilities = capabilities, + filetypes = {"python"}, +}) + diff --git a/configs/null-ls.lua b/configs/null-ls.lua new file mode 100644 index 0000000..51220e1 --- /dev/null +++ b/configs/null-ls.lua @@ -0,0 +1,27 @@ +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +local null_ls = require('null-ls') + +local opts = { + sources = { + null_ls.builtins.formatting.black, + null_ls.builtins.diagnostics.mypy, + null_ls.builtins.diagnostics.ruff, + }, + on_attach = function(client, bufnr) + if client.supports_method("textDocument/formatting") then + vim.api.nvim_clear_autocmds({ + group = augroup, + buffer = bufnr, + }) + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format({ bufnr = bufnr }) + end, + }) + end + end, +} +return opts + diff --git a/mappings.lua b/mappings.lua new file mode 100644 index 0000000..0623782 --- /dev/null +++ b/mappings.lua @@ -0,0 +1,14 @@ +local M = {} + +M.general = { + n = { + [""] = { "10+", "Move cursor forward by 10 lines"}, + [""] = { "10-", "Move cursor backward by 10 lines"}, + }, + v = { + [""] = { "10+", "Move cursor forward by 10 lines"}, + [""] = { "10-", "Move cursor backward by 10 lines"}, + }, +} + +return M diff --git a/plugins.lua b/plugins.lua new file mode 100644 index 0000000..b44f204 --- /dev/null +++ b/plugins.lua @@ -0,0 +1,25 @@ +local plugins = { + { + "nvimtools/none-ls.nvim", + ft = {"python"}, + opts = function() + return require "custom.configs.null-ls" + end, + }, + { + "neovim/nvim-lspconfig", + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, + }, + { + "github/copilot.vim", + lazy=false + }, + { + "karoliskoncevicius/vim-sendtowindow", + lazy=false + }, +} +return plugins