diff --git a/modules/old_configs/nvim/after/plugin/dap.lua b/modules/old_configs/nvim/after/plugin/dap.lua new file mode 100644 index 0000000..0990a18 --- /dev/null +++ b/modules/old_configs/nvim/after/plugin/dap.lua @@ -0,0 +1,42 @@ +local dap = require("dap") +dap.adapters.gdb = { + type = "executable", + command = "gdb", + args = { "--interpreter=dap", "--eval-command", "set print pretty on" } +} + +dap.configurations.c = { + { + name = "Launch", + type = "gdb", + request = "launch", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = "${workspaceFolder}", + stopAtBeginningOfMainSubprogram = false, + }, + { + name = "Select and attach to process", + type = "gdb", + request = "attach", + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + pid = function() + local name = vim.fn.input('Executable name (filter): ') + return require("dap.utils").pick_process({ filter = name }) + end, + cwd = '${workspaceFolder}' + }, + { + name = 'Attach to gdbserver :1234', + type = 'gdb', + request = 'attach', + target = 'localhost:1234', + program = function() + return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file') + end, + cwd = '${workspaceFolder}' + }, +} diff --git a/modules/old_configs/nvim/after/plugin/lsp.lua b/modules/old_configs/nvim/after/plugin/lsp.lua index ca11f46..9493643 100644 --- a/modules/old_configs/nvim/after/plugin/lsp.lua +++ b/modules/old_configs/nvim/after/plugin/lsp.lua @@ -1,37 +1,10 @@ -local lsp = require('lsp-zero') +local lsp_zero = require('lsp-zero') -lsp.preset('recommended') - -lsp.ensure_installed({ - --'eslint', - --'html', - --'lua_ls', - 'rust_analyzer', - 'jdtls', - --'clangd', - 'zls', - --'pylsp', - 'ols', -}) - -local cmp = require('cmp') -local cmp_select = {behaviour = cmp.SelectBehavior.Select} -local cmp_mappings = lsp.defaults.cmp_mappings({ - [''] = cmp.mapping.select_prev_item(cmp_select), - [''] = cmp.mapping.select_next_item(cmp_select), - [''] = cmp.mapping.confirm({ select = true }), - [''] = cmp.mapping.complete(), -}) - -lsp.set_preferences({ - sign_icons = { } -}) - -lsp.setup_nvim_cmp({ - mapping = cmp_mappings -}) - -lsp.on_attach(function(client, bufnr) +local lsp_attach = function(client, bufnr) + -- see :help lsp-zero-keybindings + -- to learn the available actions + -- lsp_zero.default_keymaps({buffer = bufnr}) + -- local opts = {buffer = bufnr, remap = false} vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts) @@ -45,23 +18,189 @@ lsp.on_attach(function(client, bufnr) vim.keymap.set("n", "vrr", function() vim.lsp.buf.references() end, opts) vim.keymap.set("n", "vrn", function() vim.lsp.buf.rename() end, opts) vim.keymap.set("i", "", function() vim.lsp.buf.signature_help() end, opts) -end) +end -require('lspconfig').lua_ls.setup({ - settings = { - Lua = { - diagnostics = { - globals = { 'vim', 'turtle' }, - }, - }, +lsp_zero.extend_lspconfig({ + capabilities = require('cmp_nvim_lsp').default_capabilities(), + lsp_attach = lsp_attach, + float_border = 'rounded', + sign_text = true, +}) + +local lspconfig = require('lspconfig') + +require('mason').setup({}) +require('mason-lspconfig').setup({ + ensure_installed = { + 'lua_ls', + 'jdtls', + 'clangd', + 'zls', + }, + handlers = { + function(server_name) + require('lspconfig')[server_name].setup({}) + end, + + -- noop is an empty function that doesn't do anything + clangd = function() + lspconfig.clangd.setup({ + cmd = { + 'clangd', + '--background-index', + '--clang-tidy', + '--log=verbose', + '--header-interpolation=false', -- clangd doesn't find the files, annoying and unnecessary noise as a result + }, + init_options = { + fallbackFlags = { + '-std=c23', + '-std=c++20' + }, + }, + }) + end, + jdtls = function() + lspconfig.jdtls.setup({ + cmd = { + "java", + "-Declipse.application=org.eclipse.jdt.ls.core.id1", + "-Dosgi.bundles.defaultStartLevel=4", + "-Declipse.product=org.eclipse.jdt.ls.core.product", + "-Dlog.protocol=true", + "-Dlog.level=ALL", + "-Xms1g", + "--add-modules=ALL-SYSTEM", + "--add-opens", + "java.base/java.util=ALL-UNNAMED", + "--add-opens", + "java.base/java.lang=ALL-UNNAMED", + -- + }, + single_file_support = true, + settings = { + java = { + signatureHelp = {enabled = true}, + import = {enabled = true}, + rename = {enabled = true} + } + }, + flags = { + debounce_text_changes = 150, + }, + init_options = { + bundles = {}, + }, + }) + end, + zls = lsp_zero.noop, + lua_ls = function() + lspconfig.lua_ls.setup({ + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then + return + end + 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 + } + } + }) + end, + settings = { + Lua = { + diagnostics = { + globals = { 'turtle' }, + }, + }, + }, + }) + end, + ols = function() + lspconfig.ols.setup({ + single_file_support = true, + on_attach = function (client, buffer) + print('reached ols') + end + }) + end, + } +}) + + +local cmp = require('cmp') +local cmp_select = {behaviour = cmp.SelectBehavior.Select} +cmp.setup({ + sources = { + { name = 'nvim_lsp' }, }, + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.select_prev_item(cmp_select), + [''] = cmp.mapping.select_next_item(cmp_select), + [''] = cmp.mapping.confirm({ select = true }), + [''] = cmp.mapping.complete(), + }), + formatting = lsp_zero.cmp_format(), }) -require('lspconfig').ols.setup({ - single_file_support = true, - on_attach = function (client, buffer) - print('reached ols') - end -}) +-- lsp_zero.set_preferences({ +-- sign_icons = { } +-- }) +-- +-- lsp_zero.setup_nvim_cmp({ +-- mapping = cmp_mappings +-- }) -lsp.setup() + +-- require('lspconfig').lua_ls.setup({ +-- on_init = function(client) +-- if client.workspace_folders then +-- local path = client.workspace_folders[1].name +-- if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then +-- return +-- end +-- 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 +-- } +-- } +-- }) +-- end, +-- settings = { +-- Lua = { +-- diagnostics = { +-- globals = { 'turtle' }, +-- }, +-- }, +-- }, +-- }) + +-- lsp_zero.setup() diff --git a/modules/old_configs/nvim/lua/liamm/packer.lua b/modules/old_configs/nvim/lua/liamm/packer.lua index 0c50afb..10e4332 100644 --- a/modules/old_configs/nvim/lua/liamm/packer.lua +++ b/modules/old_configs/nvim/lua/liamm/packer.lua @@ -2,15 +2,8 @@ return require('packer').startup(function(use) -- Packer can manage itself use 'wbthomason/packer.nvim' - --themes ---- commenting out ones I'm not actively using - --use ({'EdenEast/nightfox.nvim' }) - --use 'rebelot/kanagawa.nvim' --not too bad a theme - use({ 'rose-pine/neovim', as = 'rose-pine' }) --pretty nice themes - --end themes + use({ 'rose-pine/neovim', as = 'rose-pine' }) - - --use 'Tetralux/odin.vim' --odin lang syntax highlighting - --use 'rust-lang/rust.vim' // don't need this anymore use 'nvim-telescope/telescope.nvim' use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'}) use 'nvim-treesitter/playground' @@ -19,21 +12,17 @@ return require('packer').startup(function(use) use 'mbbill/undotree' use 'theprimeagen/harpoon' use 'nvim-lualine/lualine.nvim' + use 'mfussenegger/nvim-dap' -- debugger integration use 'tpope/vim-fugitive' -- git integration --LSP CONFIG -- use { 'VonHeikemen/lsp-zero.nvim', - branch = 'v2.x', + branch = 'v4.x', requires = { -- LSP Support {'neovim/nvim-lspconfig'}, -- Required - { -- Optional - 'williamboman/mason.nvim', - run = function() - pcall(vim.cmd, 'MasonUpdate') - end, - }, + {'williamboman/mason.nvim'}, -- Optional {'williamboman/mason-lspconfig.nvim'}, -- Optional -- Autocompletion @@ -50,7 +39,4 @@ return require('packer').startup(function(use) } } - use {"akinsho/toggleterm.nvim", tag = '*', config = function() - require("toggleterm").setup() - end} end) diff --git a/modules/old_configs/nvim/lua/liamm/remap.lua b/modules/old_configs/nvim/lua/liamm/remap.lua index 41bcba7..dfa6866 100644 --- a/modules/old_configs/nvim/lua/liamm/remap.lua +++ b/modules/old_configs/nvim/lua/liamm/remap.lua @@ -22,11 +22,30 @@ vim.keymap.set("n", "Y", "\"+Y") vim.keymap.set("n", "x", "!chmod +x %", {silent = true}) -- put nvim to background -vim.keymap.set("n", "z", "") +vim.keymap.set("n", "bg", "") + + +-- invoke build scripts +-- `build.sh` +vim.keymap.set("n", "bo", ":!./build.sh ") -- Interactive for adding flags/options +vim.keymap.set("n", "bb", ":!./build.sh ") +vim.keymap.set("n", "br", ":!./build.sh run") +vim.keymap.set("n", "bR", ":!./build.sh release") +vim.keymap.set("n", "bRr", ":!./build.sh release run") + +-- zig build +vim.keymap.set("n", "zbo", ":!zig build -D") -- Interactive for adding flags/options +vim.keymap.set("n", "zbb", ":!zig build ") +vim.keymap.set("n", "zbr", ":!zig build run") +vim.keymap.set("n", "zbR", ":!zig build -Doptimize=ReleaseSafe ") +vim.keymap.set("n", "zbRr", ":!zig build -Doptimize=ReleaseSafe run") +vim.keymap.set("n", "zbt", ":!zig build -Dtarget=") -- Interactive to add target/other flags +vim.keymap.set("n", "zbtR", ":!zig build -Doptimize=ReleaseSafe -Dtarget=") -- Interactive to add target/other flags + -- emacs-inspired binds -- all can be done w spacebar-w vim.keymap.set("n", "w", "") vim.keymap.set("n", "qq", ":x") nnoremap(".", ":find ~/") -nnoremap("fc", ":find ~/.config/nvim/lua/liamm/remap.lua") +nnoremap("fc", ":find ~/personal/nixos/modules/old_configs/nvim/lua/liamm/remap.lua") diff --git a/modules/old_configs/nvim/lua/liamm/set.lua b/modules/old_configs/nvim/lua/liamm/set.lua index ab65e1a..641307e 100644 --- a/modules/old_configs/nvim/lua/liamm/set.lua +++ b/modules/old_configs/nvim/lua/liamm/set.lua @@ -18,7 +18,7 @@ vim.opt.colorcolumn = "" vim.opt.smartindent = true -vim.opt.wrap = false +vim.opt.wrap = true vim.opt.swapfile = false vim.opt.backup = false