From c01eb77972a57be599ad3b1ba36640ec9a491e01 Mon Sep 17 00:00:00 2001 From: tavo Date: Tue, 7 Jan 2025 12:27:35 -0600 Subject: [PATCH] afterft --- lvim/config.lua | 8 +-- lvim/lua/config/c.lua | 121 +++---------------------------------- lvim/lua/config/go.lua | 103 +++---------------------------- npm/npmrc | 4 ++ shell/profile.d/path.sh | 1 + shell/profile.d/xdgspec.sh | 3 +- 6 files changed, 24 insertions(+), 216 deletions(-) create mode 100644 npm/npmrc diff --git a/lvim/config.lua b/lvim/config.lua index b60a1a7..df7736d 100644 --- a/lvim/config.lua +++ b/lvim/config.lua @@ -4,10 +4,6 @@ -- Forum: https://www.reddit.com/r/lunarvim/ -- Discord: https://discord.com/invite/Xb9B4Ny --- require("config.go") --- require("config.py") --- require("config.c") - lvim.plugins = { "askfiy/visual_studio_code", "sainnhe/gruvbox-material", @@ -18,4 +14,6 @@ lvim.plugins = { lvim.colorscheme = "everforest" vim.g.everforest_background = "hard" -lvim.builtin.lualine.style = "default" +require("config.go") +require("config.c") +-- require("config.py") diff --git a/lvim/lua/config/c.lua b/lvim/lua/config/c.lua index 3af4c7d..b5c5a00 100644 --- a/lvim/lua/config/c.lua +++ b/lvim/lua/config/c.lua @@ -1,115 +1,8 @@ -lvim.format_on_save = false -lvim.lsp.diagnostics.virtual_text = true - -lvim.builtin.treesitter.highlight.enable = true - --- auto install treesitter parsers -lvim.builtin.treesitter.ensure_installed = { "cpp", "c" } - --- Additional Plugins -table.insert(lvim.plugins, { - "p00f/clangd_extensions.nvim", +vim.api.nvim_create_autocmd('FileType', { + pattern = { "c", "cpp" }, + callback = function() + vim.opt.colorcolumn = "81" + vim.opt.shiftwidth = 8 + vim.opt.expandtab = false + end }) - -vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "clangd" }) - --- some settings can only passed as commandline flags, see `clangd --help` -local clangd_flags = { - "--background-index", - "--fallback-style=Google", - "--all-scopes-completion", - "--clang-tidy", - "--log=error", - "--suggest-missing-includes", - "--cross-file-rename", - "--completion-style=detailed", - "--pch-storage=memory", -- could also be disk - "--folding-ranges", - "--enable-config", -- clangd 11+ supports reading from .clangd configuration file - "--offset-encoding=utf-16", --temporary fix for null-ls - -- "--limit-references=1000", - -- "--limit-resutls=1000", - -- "--malloc-trim", - -- "--clang-tidy-checks=-*,llvm-*,clang-analyzer-*,modernize-*,-modernize-use-trailing-return-type", - -- "--header-insertion=never", - -- "--query-driver=" -} - -local provider = "clangd" - -local custom_on_attach = function(client, bufnr) - require("lvim.lsp").common_on_attach(client, bufnr) - - local opts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("n", "lh", "ClangdSwitchSourceHeader", opts) - vim.keymap.set("x", "lA", "ClangdAST", opts) - vim.keymap.set("n", "lH", "ClangdTypeHierarchy", opts) - vim.keymap.set("n", "lt", "ClangdSymbolInfo", opts) - vim.keymap.set("n", "lm", "ClangdMemoryUsage", opts) - - require("clangd_extensions.inlay_hints").setup_autocmd() - require("clangd_extensions.inlay_hints").set_inlay_hints() -end - -local status_ok, project_config = pcall(require, "rhel.clangd_wrl") -if status_ok then - clangd_flags = vim.tbl_deep_extend("keep", project_config, clangd_flags) -end - -local custom_on_init = function(client, bufnr) - require("lvim.lsp").common_on_init(client, bufnr) - require("clangd_extensions.config").setup {} - require("clangd_extensions.ast").init() - vim.cmd [[ - command ClangdToggleInlayHints lua require('clangd_extensions.inlay_hints').toggle_inlay_hints() - command -range ClangdAST lua require('clangd_extensions.ast').display_ast(, ) - command ClangdTypeHierarchy lua require('clangd_extensions.type_hierarchy').show_hierarchy() - command ClangdSymbolInfo lua require('clangd_extensions.symbol_info').show_symbol_info() - command -nargs=? -complete=customlist,s:memuse_compl ClangdMemoryUsage lua require('clangd_extensions.memory_usage').show_memory_usage('' == 'expand_preamble') - ]] -end - -local opts = { - cmd = { provider, unpack(clangd_flags) }, - on_attach = custom_on_attach, - on_init = custom_on_init, -} - -require("lvim.lsp.manager").setup("clangd", opts) - --- install codelldb with :MasonInstall codelldb --- configure nvim-dap (codelldb) -lvim.builtin.dap.on_config_done = function(dap) - dap.adapters.codelldb = { - type = "server", - port = "${port}", - executable = { - -- provide the absolute path for `codelldb` command if not using the one installed using `mason.nvim` - command = "codelldb", - args = { "--port", "${port}" }, - - -- On windows you may have to uncomment this: - -- detached = false, - }, - } - - dap.configurations.cpp = { - { - name = "Launch file", - type = "codelldb", - request = "launch", - program = function() - local path - vim.ui.input({ prompt = "Path to executable: ", default = vim.loop.cwd() .. "/build/" }, function(input) - path = input - end) - vim.cmd [[redraw]] - return path - end, - cwd = "${workspaceFolder}", - stopOnEntry = false, - }, - } - - dap.configurations.c = dap.configurations.cpp -end diff --git a/lvim/lua/config/go.lua b/lvim/lua/config/go.lua index 2a1ad03..85c07de 100644 --- a/lvim/lua/config/go.lua +++ b/lvim/lua/config/go.lua @@ -1,97 +1,8 @@ ------------------------- --- Treesitter ------------------------- -lvim.builtin.treesitter.ensure_installed = { - "go", - "gomod", -} - ------------------------- --- Plugins ------------------------- -lvim.plugins = { - "olexsmir/gopher.nvim", - "leoluz/nvim-dap-go", -} - ------------------------- --- Formatting ------------------------- -local formatters = require "lvim.lsp.null-ls.formatters" -formatters.setup { - { command = "goimports", filetypes = { "go" } }, - { command = "gofumpt", filetypes = { "go" } }, -} - -lvim.format_on_save = { - pattern = { "*.go" }, -} - ------------------------- --- Dap ------------------------- -local dap_ok, dapgo = pcall(require, "dap-go") -if not dap_ok then - return -end - -dapgo.setup() - ------------------------- --- LSP ------------------------- -vim.list_extend(lvim.lsp.automatic_configuration.skipped_servers, { "gopls" }) - -local lsp_manager = require "lvim.lsp.manager" - -lsp_manager.setup("gopls", { - on_attach = function(client, bufnr) - require("lvim.lsp").common_on_attach(client, bufnr) - local _, _ = pcall(vim.lsp.codelens.refresh) - local map = function(mode, lhs, rhs, desc) - if desc then - desc = desc - end - - vim.keymap.set(mode, lhs, rhs, { silent = true, desc = desc, buffer = bufnr, noremap = true }) - end - map("n", "Ci", "GoInstallDeps", "Install Go Dependencies") - map("n", "Ct", "GoMod tidy", "Tidy") - map("n", "Ca", "GoTestAdd", "Add Test") - map("n", "CA", "GoTestsAll", "Add All Tests") - map("n", "Ce", "GoTestsExp", "Add Exported Tests") - map("n", "Cg", "GoGenerate", "Go Generate") - map("n", "Cf", "GoGenerate %", "Go Generate File") - map("n", "Cc", "GoCmt", "Generate Comment") - map("n", "DT", "lua require('dap-go').debug_test()", "Debug Test") - end, - on_init = require("lvim.lsp").common_on_init, - capabilities = require("lvim.lsp").common_capabilities(), - settings = { - gopls = { - usePlaceholders = true, - gofumpt = true, - codelenses = { - generate = false, - gc_details = true, - test = true, - tidy = true, - }, - }, - }, +vim.api.nvim_create_autocmd('FileType', { + pattern = { "go" }, + callback = function() + vim.opt.colorcolumn = "81" + vim.opt.shiftwidth = 8 + vim.opt.expandtab = false + end }) - -local status_ok, gopher = pcall(require, "gopher") -if not status_ok then - return -end - -gopher.setup { - commands = { - go = "go", - gomodifytags = "gomodifytags", - gotests = "gotests", - impl = "impl", - iferr = "iferr", - }, -} diff --git a/npm/npmrc b/npm/npmrc new file mode 100644 index 0000000..b12cc98 --- /dev/null +++ b/npm/npmrc @@ -0,0 +1,4 @@ +prefix=${XDG_DATA_HOME}/npm +cache=${XDG_CACHE_HOME}/npm +init-module=${XDG_CONFIG_HOME}/npm/config/npm-init.js +logs-dir=${XDG_STATE_HOME}/npm/logs diff --git a/shell/profile.d/path.sh b/shell/profile.d/path.sh index b4c662b..ca3c5dd 100644 --- a/shell/profile.d/path.sh +++ b/shell/profile.d/path.sh @@ -8,3 +8,4 @@ PATH="$HOME/.config/scripts${PATH:+:${PATH}}" PATH="$HOME/.local/bin${PATH:+:${PATH}}" PATH="$HOME/.local/state/nix/profile/bin${PATH:+:${PATH}}" PATH="$HOME/.config/emacs/bin${PATH:+:${PATH}}" +PATH="$HOME/.local/share/go/bin${PATH:+:${PATH}}" diff --git a/shell/profile.d/xdgspec.sh b/shell/profile.d/xdgspec.sh index 5c3ed14..3481bd9 100644 --- a/shell/profile.d/xdgspec.sh +++ b/shell/profile.d/xdgspec.sh @@ -27,4 +27,5 @@ export \ GOPATH="$XDG_DATA_HOME/go" \ SSH_CONFIG="-F ${XDG_CONFIG_HOME}/ssh/config" \ GIT_SSH_COMMAND="ssh -F ${XDG_CONFIG_HOME}/ssh/config" \ - ZDOTDIR="$XDG_CONFIG_HOME/shell" + ZDOTDIR="$XDG_CONFIG_HOME/shell" \ + NPM_CONFIG_USERCONFIG=$XDG_CONFIG_HOME/npm/npmrc