diff --git a/after/ftplugin/fsharp.lua b/after/ftplugin/fsharp.lua new file mode 100644 index 00000000..9aa3038e --- /dev/null +++ b/after/ftplugin/fsharp.lua @@ -0,0 +1 @@ +vim.opt_local.expandtab = true diff --git a/ftplugin/fsharp.lua b/ftplugin/fsharp.lua new file mode 100644 index 00000000..9aa3038e --- /dev/null +++ b/ftplugin/fsharp.lua @@ -0,0 +1 @@ +vim.opt_local.expandtab = true diff --git a/ftplugin/ft.lua b/ftplugin/ft.lua new file mode 100644 index 00000000..1538f8e0 --- /dev/null +++ b/ftplugin/ft.lua @@ -0,0 +1,6 @@ +vim.filetype.add { + extension = { + fsx = 'fsharp', + fs = 'fsharp', + }, +} diff --git a/init.lua b/init.lua index 4eae8e7d..bbfe30d5 100644 --- a/init.lua +++ b/init.lua @@ -102,7 +102,7 @@ vim.g.have_nerd_font = false vim.opt.number = true -- You can also add relative line numbers, to help with jumping. -- Experiment for yourself to see if you like it! --- vim.opt.relativenumber = true +vim.opt.relativenumber = true -- Enable mouse mode, can be useful for resizing splits for example! vim.opt.mouse = 'a' @@ -175,10 +175,10 @@ vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagn vim.keymap.set('t', '', '', { desc = 'Exit terminal mode' }) -- TIP: Disable arrow keys in normal mode --- vim.keymap.set('n', '', 'echo "Use h to move!!"') --- vim.keymap.set('n', '', 'echo "Use l to move!!"') --- vim.keymap.set('n', '', 'echo "Use k to move!!"') --- vim.keymap.set('n', '', 'echo "Use j to move!!"') +vim.keymap.set('n', '', 'echo "Use h to move!!"') +vim.keymap.set('n', '', 'echo "Use l to move!!"') +vim.keymap.set('n', '', 'echo "Use k to move!!"') +vim.keymap.set('n', '', 'echo "Use j to move!!"') -- Keybinds to make split navigation easier. -- Use CTRL+ to switch between windows @@ -229,7 +229,18 @@ vim.opt.rtp:prepend(lazypath) require('lazy').setup({ -- NOTE: Plugins can be added with a link (or for a github repo: 'owner/repo' link). 'tpope/vim-sleuth', -- Detect tabstop and shiftwidth automatically - + 'ionide/Ionide-vim', + { + 'DanielGavin/ols', + opts = { + init_options = { + checker_args = '-strict-style', + collections = { + { name = 'shared', path = vim.fn.expand '$HOME/odin-lib' }, + }, + }, + }, + }, -- NOTE: Plugins can also be added by using a table, -- with the first argument being the link and the following -- keys can be used to configure plugin behavior/loading/etc. @@ -435,6 +446,18 @@ require('lazy').setup({ vim.keymap.set('n', 'sn', function() builtin.find_files { cwd = vim.fn.stdpath 'config' } end, { desc = '[S]earch [N]eovim files' }) + -- Shortcut for searching your Odin source files + vim.keymap.set('n', 'so', function() + builtin.find_files { cwd = '/home/default/.odin' } + end, { desc = '[S]earch [O]din source files' }) + -- Shortcut for searching your Odin source files + vim.keymap.set('n', 'sog', function() + builtin.live_grep { cwd = '/home/default/.odin' } + end, { desc = '[S]earch [O]din by [G]rep' }) + -- Shortcut for fuzzy finding your Odin source files + vim.keymap.set('n', 'sof', function() + builtin.grep_string { shorten_path = true, word_match = '-w', only_sort_text = true, search = '', cwd = '/home/default/.odin' } + end, { desc = '[S]earch [O]din by [F]uzzy' }) end, }, @@ -461,7 +484,7 @@ require('lazy').setup({ { 'williamboman/mason.nvim', opts = {} }, 'williamboman/mason-lspconfig.nvim', 'WhoIsSethDaniel/mason-tool-installer.nvim', - + 'nvim-java/nvim-java', -- Useful status updates for LSP. { 'j-hui/fidget.nvim', opts = {} }, @@ -616,6 +639,8 @@ require('lazy').setup({ -- - settings (table): Override the default settings passed when initializing the server. -- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/ local servers = { + fsautocomplete = {}, + --jdtls = {}, -- clangd = {}, -- gopls = {}, -- pyright = {}, @@ -626,7 +651,7 @@ require('lazy').setup({ -- https://github.com/pmizio/typescript-tools.nvim -- -- But for many setups, the LSP (`ts_ls`) will work just fine - -- ts_ls = {}, + --ts_ls = {}, -- lua_ls = { @@ -665,6 +690,8 @@ require('lazy').setup({ require('mason-tool-installer').setup { ensure_installed = ensure_installed } require('mason-lspconfig').setup { + ensure_installed = {}, -- explicitly set to an empty table (Kickstart populates installs via mason-tool-installer) + automatic_installation = false, handlers = { function(server_name) local server = servers[server_name] or {} @@ -902,7 +929,7 @@ require('lazy').setup({ main = 'nvim-treesitter.configs', -- Sets main module to use for opts -- [[ Configure Treesitter ]] See `:help nvim-treesitter` opts = { - ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc' }, + ensure_installed = { 'bash', 'c', 'diff', 'html', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'query', 'vim', 'vimdoc', 'java' }, -- Autoinstall languages that are not installed auto_install = true, highlight = { diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index be0eb9d8..ed1f839c 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -2,4 +2,97 @@ -- I promise not to create any merge conflicts in this directory :) -- -- See the kickstart.nvim README for more information -return {} +return { + { + 'mfussenegger/nvim-dap', + dependencies = { + 'leoluz/nvim-dap-go', + 'rcarriga/nvim-dap-ui', + 'theHamsta/nvim-dap-virtual-text', + 'nvim-neotest/nvim-nio', + 'williamboman/mason.nvim', + }, + config = function() + local dap = require 'dap' + local ui = require 'dapui' + + require('dapui').setup() + require('dap-go').setup() + + require('nvim-dap-virtual-text').setup { + -- This just tries to mitigate the chance that I leak tokens here. Probably won't stop it from happening... + display_callback = function(variable) + local name = string.lower(variable.name) + local value = string.lower(variable.value) + if name:match 'secret' or name:match 'api' or value:match 'secret' or value:match 'api' then + return '*****' + end + + if #variable.value > 15 then + return ' ' .. string.sub(variable.value, 1, 15) .. '... ' + end + + return ' ' .. variable.value + end, + } + + -- Handled by nvim-dap-go + -- dap.adapters.go = { + -- type = "server", + -- port = "${port}", + -- executable = { + -- command = "dlv", + -- args = { "dap", "-l", "127.0.0.1:${port}" }, + -- }, + -- } + + local elixir_ls_debugger = vim.fn.exepath 'elixir-ls-debugger' + if elixir_ls_debugger ~= '' then + dap.adapters.mix_task = { + type = 'executable', + command = elixir_ls_debugger, + } + + dap.configurations.elixir = { + { + type = 'mix_task', + name = 'phoenix server', + task = 'phx.server', + request = 'launch', + projectDir = '${workspaceFolder}', + exitAfterTaskReturns = false, + debugAutoInterpretAllModules = false, + }, + } + end + + vim.keymap.set('n', 'b', dap.toggle_breakpoint) + vim.keymap.set('n', 'gb', dap.run_to_cursor) + + -- Eval var under cursor + vim.keymap.set('n', '?', function() + require('dapui').eval(nil, { enter = true }) + end) + + vim.keymap.set('n', '', dap.continue) + vim.keymap.set('n', '', dap.step_into) + vim.keymap.set('n', '', dap.step_over) + vim.keymap.set('n', '', dap.step_out) + vim.keymap.set('n', '', dap.step_back) + vim.keymap.set('n', '', dap.restart) + + dap.listeners.before.attach.dapui_config = function() + ui.open() + end + dap.listeners.before.launch.dapui_config = function() + ui.open() + end + dap.listeners.before.event_terminated.dapui_config = function() + ui.close() + end + dap.listeners.before.event_exited.dapui_config = function() + ui.close() + end + end, + }, +} diff --git a/plugin/floaterminal.lua b/plugin/floaterminal.lua new file mode 100644 index 00000000..fd64f747 --- /dev/null +++ b/plugin/floaterminal.lua @@ -0,0 +1,62 @@ +local state = { + floating = { + buf = -1, + win = -1, + }, +} +-- Create a floating window with a terminal +function create_floating_terminal(opts) + -- Get the width and height of the current screen + local width = vim.o.columns + local height = vim.o.lines + + -- Define the size of the floating window (you can adjust this to your needs) + local win_width = opts.width or math.floor(width * 0.6) -- 60% of screen width + local win_height = opts.height or math.floor(height * 0.5) -- 50% of screen height + + -- Center the window + local row = math.floor((height - win_height) / 2) + local col = math.floor((width - win_width) / 2) + + local buf = nil + if vim.api.nvim_buf_is_valid(opts.buf) then + buf = opts.buf + else + buf = vim.api.nvim_create_buf(false, true) -- Create an empty buffer + end + + -- Define the border highlight group (adjust this to the color you prefer) + local border_color = 'ColorColumn' -- Change to any highlight group of your choice + + -- Define window options + local windowOptions = { + relative = 'editor', + width = win_width, + height = win_height, + col = col, + row = row, + style = 'minimal', -- We don't need any status line or title + border = 'rounded', + } + + -- Open the floating window with a terminal + + local win = vim.api.nvim_open_win(buf, true, windowOptions) -- Open the floating window + + -- Open a terminal inside the buffer + return { buf = buf, win = win } +end + +local toggleTerminal = function() + if not vim.api.nvim_win_is_valid(state.floating.win) then + state.floating = create_floating_terminal { buf = state.floating.buf } + if vim.bo[state.floating.buf].buftype ~= 'terminal' then + vim.cmd.terminal() + end + else + vim.api.nvim_win_hide(state.floating.win) + end +end +vim.api.nvim_create_user_command('Floaterminal', toggleTerminal, {}) +-- Key mapping to open the floating terminal +vim.keymap.set({ 'n', 't' }, 'tt', toggleTerminal)