From d5faa082533b145e1ff37258c5179fca5b930c85 Mon Sep 17 00:00:00 2001 From: Dario48true Date: Wed, 30 Apr 2025 20:08:59 +0200 Subject: [PATCH] flippity fuck --- init.lua | 1 - lua/config/autocmd.lua | 6 ---- lua/config/general.lua | 2 ++ lua/plugins/conformer.lua | 56 +++++++++++++++++++++++++++++------ lua/plugins/darioline.lua | 4 +++ lua/plugins/lspconfig.lua | 62 ++++++++++++++++++++++++++------------- lua/plugins/mason.lua | 50 +++++++++++++++++++++++++++---- lua/plugins/nvim-cmp.lua | 54 +++++++++++++++++++++++++--------- lua/plugins/nvim-lint.lua | 19 ++++++++++++ lua/plugins/suda.lua | 3 ++ lua/plugins/which-key.lua | 1 + 11 files changed, 201 insertions(+), 57 deletions(-) create mode 100644 lua/plugins/darioline.lua create mode 100644 lua/plugins/nvim-lint.lua create mode 100644 lua/plugins/suda.lua diff --git a/init.lua b/init.lua index 3230341..3b6dc97 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,3 @@ require("config.lazy") require("config.general") require("config.autocmd") - diff --git a/lua/config/autocmd.lua b/lua/config/autocmd.lua index 77e01ac..e69de29 100644 --- a/lua/config/autocmd.lua +++ b/lua/config/autocmd.lua @@ -1,6 +0,0 @@ -vim.api.nvim_create_autocmd("BufWritePre", { - pattern = "*", - callback = function(args) - require("conform").format({ bufnr = args.buf }) - end, -}) diff --git a/lua/config/general.lua b/lua/config/general.lua index f1418ca..c0a412b 100644 --- a/lua/config/general.lua +++ b/lua/config/general.lua @@ -23,3 +23,5 @@ vim.opt.scrolloff = 6 vim.cmd("nnoremap j gj") vim.cmd("nnoremap k gk") + +vim.g.zig_fmt_parse_errors = 0 diff --git a/lua/plugins/conformer.lua b/lua/plugins/conformer.lua index 1a0e2c5..b2acafc 100644 --- a/lua/plugins/conformer.lua +++ b/lua/plugins/conformer.lua @@ -1,12 +1,50 @@ return { "stevearc/conform.nvim", - opts = { - formatters_by_ft = { - lua = { "stylua" }, - js = { "prettierd" }, - html = { "prettierd" }, - c = { "clang-format" }, - cpp = { "clang-format" }, - }, - }, + event = { "BufWritePre" }, + cmd = { "ConformInfo" }, + init = function() + require "conform".setup( + { + format_on_save = function(bufnr) + require("conform").formatters_by_ft = require "mason-bridge".get_formatters() + return { timeout_ms = 200, lsp_fallback = true }, on_format + end, + formatters_by_ft = require("mason-bridge").get_formatters(), --[[ = { + lua = { "stylua" }, + javascript = { "prettier" }, + html = { "prettier" }, + css = { "prettier" }, + c = { "clang-format" }, + cpp = { "clang-format" }, + arduino = { "clang-format" }, + sh = { "shfmt" }, + bash = { "shfmt" }, + mksh = { "shfmt" }, + json = { "jq" }, + }, ]] -- + + -- This will provide type hinting with LuaLS + ---@module "conform" + ---@type conform.setupOpts + formatters = { + prettier = { + prepend_args = { "--use-tabs", "true" }, + }, + jq = { + prepend_args = { "--tab" }, + }, + ["clang-format"] = { + prepend_args = function(self, ctx) + return { "-style=file:/home/Dario48/.config/.clang-format" } + end, + }, + default_format_opts = { + lsp_format = "fallback", + }, + }, + }) + -- If you want the formatexpr, here is the place to set it + vim.o.formatexpr = "v:lua.require'conform'.formatexpr()" + vim.g.arduino_recommended_style = 0 + end, } diff --git a/lua/plugins/darioline.lua b/lua/plugins/darioline.lua new file mode 100644 index 0000000..0f32fc7 --- /dev/null +++ b/lua/plugins/darioline.lua @@ -0,0 +1,4 @@ +return { + url = "https://codeberg.org/Dario48/darioline.git", + config = true +} diff --git a/lua/plugins/lspconfig.lua b/lua/plugins/lspconfig.lua index 9581902..0129cb7 100644 --- a/lua/plugins/lspconfig.lua +++ b/lua/plugins/lspconfig.lua @@ -1,39 +1,59 @@ return { "neovim/nvim-lspconfig", dependencies = { - {'hrsh7th/cmp-nvim-lsp'}, - {'hrsh7th/nvim-cmp'}, + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/nvim-cmp" }, }, config = function() -- Reserve a space in the gutter -- This will avoid an annoying layout shift in the screen - vim.opt.signcolumn = 'yes' + vim.opt.signcolumn = "yes" -- Add cmp_nvim_lsp capabilities settings to lspconfig -- This should be executed before you configure any language server - local lspconfig_defaults = require('lspconfig').util.default_config + local lspconfig_defaults = require("lspconfig").util.default_config lspconfig_defaults.capabilities = vim.tbl_deep_extend( - 'force', - lspconfig_defaults.capabilities, - require('cmp_nvim_lsp').default_capabilities() + "force", + lspconfig_defaults.capabilities, + require("cmp_nvim_lsp").default_capabilities() ) - vim.api.nvim_create_autocmd('LspAttach', { - desc = 'LSP actions', + vim.api.nvim_create_autocmd("LspAttach", { + desc = "LSP actions", callback = function(event) - local opts = {buffer = event.buf} + local opts = { buffer = event.buf } - vim.keymap.set('n', 'K', function () vim.lsp.buf.hover() end, opts) - vim.keymap.set('n', 'gd', function () vim.lsp.buf.definition() end, opts) - vim.keymap.set('n', 'gD', function () vim.lsp.buf.declaration() end, opts) - vim.keymap.set('n', 'gi', function () vim.lsp.buf.implementation() end, opts) - vim.keymap.set('n', 'go', function () vim.lsp.buf.type_definition() end, opts) - vim.keymap.set('n', 'gr', function () vim.lsp.buf.references() end, opts) - vim.keymap.set('n', 'gs', function () vim.lsp.buf.signature_help() end, opts) - vim.keymap.set('n', '', function () vim.lsp.buf.rename() end, opts) - vim.keymap.set({'n', 'x'}, '', function () vim.lsp.buf.format({async = true}) end, opts) - vim.keymap.set('n', '', function () vim.lsp.buf.code_action() end, opts) + vim.keymap.set("n", "K", function() + vim.lsp.buf.hover() + end, opts) + vim.keymap.set("n", "gd", function() + vim.lsp.buf.definition() + end, opts) + vim.keymap.set("n", "gD", function() + vim.lsp.buf.declaration() + end, opts) + vim.keymap.set("n", "gi", function() + vim.lsp.buf.implementation() + end, opts) + vim.keymap.set("n", "go", function() + vim.lsp.buf.type_definition() + end, opts) + vim.keymap.set("n", "gr", function() + vim.lsp.buf.references() + end, opts) + vim.keymap.set("n", "gs", function() + vim.lsp.buf.signature_help() + end, opts) + vim.keymap.set("n", "", function() + vim.lsp.buf.rename() + end, opts) + vim.keymap.set({ "n", "x" }, "", function() + vim.lsp.buf.format({ async = true }) + end, opts) + vim.keymap.set("n", "f", function() + vim.lsp.buf.code_action() + end, opts) end, }) - end + end, } diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index 87d89cc..1a6ba51 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -2,24 +2,62 @@ return { { "williamboman/mason.nvim", - dependencies = {"williamboman/mason-lspconfig.nvim"}, + dependencies = { "williamboman/mason-lspconfig.nvim" }, keys = { { "m", ":Mason ", desc = "open mason" }, }, - config = true; + config = true, }, { "williamboman/mason-lspconfig.nvim", opts = { - -- Replace the language servers listed here + -- Replace the language servers listed here -- with the ones you want to install - ensure_installed = {'lua_ls', 'pyright'}, + ensure_installed = { "lua_ls", "clangd", "hyprls", "lua_ls" }, handlers = { function(server_name) - require('lspconfig')[server_name].setup({}) + require("lspconfig")[server_name].setup({ + }) end, + + ["lua_ls"] = function() + require 'lspconfig'.lua_ls.setup { + on_init = function(client) + local path = client.workspace_folders[1].name + if vim.loop.fs_stat(path .. '/.luarc.json') or vim.loop.fs_stat(path .. '/.luarc.jsonc') then + return + end + + client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = 'LuaJIT' + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + } + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + } + }) + end, + settings = { + Lua = {} + } + } + end }, - } + }, + }, + { + "frostplexx/mason-bridge.nvim", }, } diff --git a/lua/plugins/nvim-cmp.lua b/lua/plugins/nvim-cmp.lua index 7e218e4..ba47702 100644 --- a/lua/plugins/nvim-cmp.lua +++ b/lua/plugins/nvim-cmp.lua @@ -1,19 +1,33 @@ return { "hrsh7th/nvim-cmp", dependencies = { - 'hrsh7th/cmp-nvim-lsp', - 'hrsh7th/cmp-buffer', - 'hrsh7th/cmp-path', - 'hrsh7th/cmp-cmdline', - 'neovim/nvim-lspconfig' + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-cmdline", + "hrsh7th/cmp-nvim-lua", + "neovim/nvim-lspconfig", + "mtoohey31/cmp-fish", + "petertriho/cmp-git", }, - config= function() - local cmp = require('cmp') + config = function() + local cmp = require("cmp") cmp.setup({ sources = { - {name = 'nvim_lsp'}, + { name = "nvim_lua" }, + { + name = "nvim_lsp", + entry_filter = function(entry, ctx) + local kind = require("cmp.types").lsp.CompletionItemKind[entry:get_kind()] + + if kind == "Text" then + return false + end + return true + end, + }, { name = "neorg" }, + { name = "fish" }, }, snippet = { expand = function(args) @@ -21,13 +35,25 @@ return { vim.snippet.expand(args.body) end, }, + cmp.setup.filetype("gitcommit", { + sources = cmp.config.sources({ + { name = "git" }, + }, { + { name = "buffer" }, + }), + }), + require("cmp_git").setup(), + + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, mapping = cmp.mapping.preset.insert({ - [''] = cmp.mapping.complete(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(-4), - [' '] = cmp.mapping.confirm(), - [''] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(-4), + [" "] = cmp.mapping.confirm(), }), }) - end + end, } diff --git a/lua/plugins/nvim-lint.lua b/lua/plugins/nvim-lint.lua new file mode 100644 index 0000000..b84db48 --- /dev/null +++ b/lua/plugins/nvim-lint.lua @@ -0,0 +1,19 @@ +return { + "mfussenegger/nvim-lint", + init = function() + vim.api.nvim_create_autocmd({ "BufWritePost" }, { + callback = function() + require "lint".try_lint() + end, + }) + + vim.diagnostic.config({ + signs = true, + underline = true, + update_in_insert = false, + virtual_text = true, + }) + + require("lint").linters_by_ft = require("mason-bridge").get_linters() + end +} diff --git a/lua/plugins/suda.lua b/lua/plugins/suda.lua new file mode 100644 index 0000000..f255b6f --- /dev/null +++ b/lua/plugins/suda.lua @@ -0,0 +1,3 @@ +return { + "lambdalisue/vim-suda", +} diff --git a/lua/plugins/which-key.lua b/lua/plugins/which-key.lua index 939f119..42dc55f 100644 --- a/lua/plugins/which-key.lua +++ b/lua/plugins/which-key.lua @@ -1,3 +1,4 @@ return { "folke/which-key.nvim", + dependencies = { "nvim-tree/nvim-web-devicons" }, }