diff --git a/lua/chadrc.lua b/lua/chadrc.lua index da4779c..c214646 100644 --- a/lua/chadrc.lua +++ b/lua/chadrc.lua @@ -6,7 +6,7 @@ local M = {} M.base46 = { - theme = "onedark", + theme = "bearded-arc", -- hl_override = { -- Comment = { italic = true }, diff --git a/lua/configs/conform.lua b/lua/configs/conform.lua index 35ba6cf..3f21923 100644 --- a/lua/configs/conform.lua +++ b/lua/configs/conform.lua @@ -3,6 +3,9 @@ local options = { lua = { "stylua" }, -- css = { "prettier" }, -- html = { "prettier" }, + -- python = { "isort", "black" }, + python = { "ruff" }, + yaml = { "prettier" }, }, -- format_on_save = { diff --git a/lua/configs/lspconfig.lua b/lua/configs/lspconfig.lua index 478df01..66634ea 100644 --- a/lua/configs/lspconfig.lua +++ b/lua/configs/lspconfig.lua @@ -4,7 +4,7 @@ require("nvchad.configs.lspconfig").defaults() local lspconfig = require "lspconfig" -- EXAMPLE -local servers = { "html", "cssls" } +local servers = { "html", "cssls", "ruff_lsp", "jedi_language_server", "yls", "lua_ls" } local nvlsp = require "nvchad.configs.lspconfig" -- lsps with default config @@ -22,3 +22,13 @@ end -- on_init = nvlsp.on_init, -- capabilities = nvlsp.capabilities, -- } + +lspconfig.lua_ls.setup({ + settings = { + Lua = { + diagnostics = { + globals = { "vim" }, + }, + }, + }, +}) diff --git a/lua/mappings.lua b/lua/mappings.lua index 783b78f..6aee02c 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -3,8 +3,47 @@ require "nvchad.mappings" -- add yours here local map = vim.keymap.set +local g = vim.g +local diag = vim.diagnostic map("n", ";", ":", { desc = "CMD enter command mode" }) map("i", "jk", "") -- map({ "n", "i", "v" }, "", " w ") + +map("n", "ca", function() + vim.lsp.buf.code_action() +end, { desc = "LSP code action" }) +map("n", "tt", function() + require("base46").toggle_transparency() +end, { desc = "Toggle transparency" }) + +map("n", "J", "mzJ`z", { desc = "Concatenate line below cursor but does not move the cursor" }) + +map("n", "o", ':call append(line("."), repeat([""], v:count1))', { desc = "Insert line below" }) +map("n", "O", ':call append(line(".")-1, repeat([""], v:count1))', { desc = "Insert line above" }) + +map("n", "", "zz") +map("n", "", "zz") + +map("n", "lg", " LazyGit", { desc = "LazyGit" }) + +-- Visual mode +map("v", "J", ":m '>+1gv=gv", { desc = "Move line w/indentation" }) +map("v", "K", ":m '<-2gv=gv", { desc = "Move line w/indentation" }) + +map("v", ">", ">gv", { desc = "indent" }) +map("v", "<", "lt", Toggle_diagnostics, { noremap = true, silent = true, desc = "Toggle vim diagnostics" }) diff --git a/lua/options.lua b/lua/options.lua index 738f20b..a7630c8 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -2,5 +2,19 @@ require "nvchad.options" -- add yours here! --- local o = vim.o +local o = vim.o +local opt = vim.opt -- o.cursorlineopt ='both' -- to enable cursorline! + +o.scrolloff = 10 +opt.relativenumber = true + +local highlight_group = vim.api.nvim_create_augroup("yankhighlight", { clear = true }) +vim.api.nvim_create_autocmd("textyankpost", { + callback = function() + vim.highlight.on_yank() + end, + group = highlight_group, + pattern = "*", +}) + diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua index 6474776..7a5674a 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -1,8 +1,10 @@ +local vim = vim return { { "stevearc/conform.nvim", -- event = 'BufWritePre', -- uncomment for format on save opts = require "configs.conform", + event = { "BufReadPre", "BufNewFile" }, }, -- These are some examples, uncomment them if you want to see them work! @@ -13,6 +15,37 @@ return { end, }, + { + "mfussenegger/nvim-lint", + lazy = true, + event = { "BufReadPre", "BufNewFile" }, + config = function() + local lint = require "lint" + + lint.linters_by_ft = { + python = { "ruff" }, + yaml = { "yamllint" }, + lua = { "selene" }, + } + + local ns = lint.get_namespace "ruff" + vim.diagnostic.config({ virtual_text = false, underline = false }, ns) + + local lint_augroup = vim.api.nvim_create_augroup("lint", { clear = true }) + + vim.api.nvim_create_autocmd({ "BufEnter", "BufWritePost", "InsertLeave" }, { + group = lint_augroup, + callback = function() + lint.try_lint() + end, + }) + + vim.keymap.set("n", "ld", function() + lint.try_lint() + end, { desc = "Trigger linting for current file" }) + end, + }, + -- { -- "nvim-treesitter/nvim-treesitter", -- opts = { @@ -22,4 +55,74 @@ return { -- }, -- }, -- }, + { + "rktjmp/paperplanes.nvim", + opts = { + provider = "dpaste.org", + }, + }, + { + "NvChad/nvcommunity", + { import = "nvcommunity.git.diffview" }, + { import = "nvcommunity.git.lazygit" }, + { import = "nvcommunity.completion.copilot" }, + { + "copilot.lua", + -- opts = { + -- ... + -- }, + }, + }, + + { + "folke/trouble.nvim", + opts = {}, -- for default options, refer to the configuration section for custom setup. + cmd = "Trouble", + keys = { + { + "tx", + "Trouble diagnostics toggle", + desc = "Diagnostics (Trouble)", + }, + { + "tX", + "Trouble diagnostics toggle filter.buf=0", + desc = "Buffer Diagnostics (Trouble)", + }, + { + "cs", + "Trouble symbols toggle focus=false", + desc = "Symbols (Trouble)", + }, + { + "cl", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP Definitions / references / ... (Trouble)", + }, + { + "tL", + "Trouble loclist toggle", + desc = "Location List (Trouble)", + }, + { + "tQ", + "Trouble qflist toggle", + desc = "Quickfix List (Trouble)", + }, + }, + }, + + { + "tpope/vim-surround", + lazy = false, + }, + + -- Install a plugin + { + "max397574/better-escape.nvim", + event = "InsertEnter", + config = function() + require("better_escape").setup() + end, + }, }