diff --git a/.config/fish/config.fish b/.config/fish/config.fish index 0f6fb42..39762ce 100644 --- a/.config/fish/config.fish +++ b/.config/fish/config.fish @@ -12,7 +12,8 @@ set -gx EDITOR nvim set -gx MANPAGER "sh -c 'col -bx | bat -l man -p'" set -gx DOTNET_CLI_TELEMETRY_OPTOUT 1 -bind -M insert \cx restore_job + +bind \cx restore_job if [ (uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/ip') ] set -gx DISPLAY 127.0.0.1:0.0 @@ -78,4 +79,4 @@ function fish_prompt --description 'Write out the prompt; do not replace this. I vterm_prompt_end end -set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX $HOME ; set -gx PATH $HOME/.cabal/bin $PATH /home/joe/.ghcup/bin # ghcup-env \ No newline at end of file +set -q GHCUP_INSTALL_BASE_PREFIX[1]; or set GHCUP_INSTALL_BASE_PREFIX $HOME ; set -gx PATH $HOME/.cabal/bin $PATH /home/joe/.ghcup/bin # ghcup-env diff --git a/.config/fish/functions/m.fish b/.config/fish/functions/m.fish new file mode 100644 index 0000000..c437b2d --- /dev/null +++ b/.config/fish/functions/m.fish @@ -0,0 +1,3 @@ +function m --wraps=magit --description 'alias m magit' + magit $argv; +end diff --git a/.config/fish/functions/restore_job.fish b/.config/fish/functions/restore_job.fish index e7f939a..dfa3f0b 100644 --- a/.config/fish/functions/restore_job.fish +++ b/.config/fish/functions/restore_job.fish @@ -1,6 +1,6 @@ function restore_job if jobs > /dev/null fg - fish_prompt + clear end end diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index d9c4dc5..61893ec 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -4,7 +4,17 @@ local set = vim.opt set.clipboard = 'unnamedplus' set.wrap = false -set.number = true set.relativenumber = true set.ignorecase = true set.smartcase = true set.termguicolors = true set.swapfile = false set.backup = false set.undodir = os.getenv("XDG_CACHE_HOME") .. "/nvim/undo" set.undofile = true set.hlsearch = false +set.linebreak = true +set.number = true +set.relativenumber = true +set.ignorecase = true +set.smartcase = true +set.termguicolors = true +set.swapfile = false +set.backup = false +set.undodir = os.getenv('XDG_CACHE_HOME') .. '/nvim/undo' +set.undofile = true +set.hlsearch = false set.incsearch = true set.cursorline = true -- set.cmdheight = 0 @@ -13,31 +23,31 @@ set.mouse = 'a' set.splitright = true set.splitbelow = true set.updatetime = 600 -set.signcolumn = "yes" +set.signcolumn = 'yes' set.tabstop = 4 set.softtabstop = 4 set.shiftwidth = 4 set.expandtab = true -vim.g.mapleader = " " +vim.g.mapleader = ' ' -map("v", "J", ":m '>+1gv=gv") -map("v", "K", ":m '<-2gv=gv") -map("x", "J", ":m '>+1gv-gv", opts) -map("x", "K", ":m '<-2gv-gv", opts) +map('v', 'J', ":m '>+1gv=gv") +map('v', 'K', ":m '<-2gv=gv") +map('x', 'J', ":m '>+1gv-gv", opts) +map('x', 'K', ":m '<-2gv-gv", opts) -map("v", "<", "", ">gv", opts) +map('v', "<", '", '>gv', opts) -map("n", "J", "mzJ`z") +map('n', 'J', 'mzJ`z') -map("n", "", vim.cmd.w) -map("n", "", vim.cmd.wq) -map("n", "", vim.cmd.source) -map("n", "", "") +map('n', '', vim.cmd.w) +map('n', '', vim.cmd.wq) +map('n', '', vim.cmd.source) +map('n', '', "") -map("n", "vv", "^vg_", { noremap = true }) +map('n', 'vv', "^vg_", { noremap = true }) -map("n", "-", vim.cmd.Ex, {}) +map('n', '-', vim.cmd.Ex, {}) map('n', 'U', vim.cmd.redo) local ts = require('telescope.builtin') @@ -47,6 +57,8 @@ map('n', 'g', ts.live_grep, {}) map('n', 'b', ts.buffers, {}) map('n', 't', ts.help_tags, {}) map('n', 'c', ts.commands, {}) +map('n', 'd', ts.diagnostics, {}) +map('n', 's', ts.lsp_document_symbols, {}) -- TODO If we use this one a lot, might be better to bind it to something easier map('n', 'bb', ':b#') @@ -68,10 +80,10 @@ map('n', 'wj', 'J') map('n', 'wk', 'K') map('n', 'wl', 'L') -map("n", "", ":resize -2", opts) -map("n", "", ":resize +2", opts) -map("n", "", ":vertical resize -2", opts) -map("n", "", ":vertical resize +2", opts) +map('n', '', ':resize -2', opts) +map('n', '', ':resize +2', opts) +map('n', '', ':vertical resize -2', opts) +map('n', '', ':vertical resize +2', opts) map('n', '', 'h', {}) map('n', '', 'j', {}) @@ -82,14 +94,14 @@ map('n', '', 'l', {}) -- -- neogit.setup {} -map("n", "tw", ":set wrap!") +map('n', 'tw', ':set wrap!') function get_lsp_client_info() -- local info = vim.lsp.buf.completion() - local pickers = require "telescope.pickers" - local finders = require "telescope.finders" - local previewers = require "telescope.previewers" - local conf = require("telescope.config").values + local pickers = require 'telescope.pickers' + local finders = require 'telescope.finders' + local previewers = require 'telescope.previewers' + local conf = require('telescope.config').values local params = vim.lsp.util.make_position_params() opts = opts or {} @@ -98,22 +110,22 @@ function get_lsp_client_info() client.request('textDocument/completion', params, function(arg1, arg2, arg3, arg4) local i = 0 for key,value in pairs(arg2.items) do - if value.textEdit.newText ~= nil and value.textEdit.newText ~= "" and i < 100 then + if value.textEdit.newText ~= nil and value.textEdit.newText ~= '' and i < 100 then table.insert(comp_text, value.textEdit.newText) i = i + 1 end end pickers.new(opts, { - prompt_title = "Lsp autocomplete", + prompt_title = 'Lsp autocomplete', finder = finders.new_table { - -- results = { "red", "green", "blue" } + -- results = { 'red', 'green', 'blue' } results = comp_text }, previewer = previewers.new_buffer_previewer( { - title = "LSP Documentation", + title = 'LSP Documentation', define_preview = function(self, entry, status) - return "DO IT" + return 'DO IT' end } ), @@ -124,34 +136,3 @@ function get_lsp_client_info() end map('i', '', get_lsp_client_info) - --- _request('textDocument/completion', params, function(err, response) --- if err or response == nil then --- return args.abort() --- end --- args.callback(compe.helper.convert_lsp({ --- keyword_pattern_offset = args.keyword_pattern_offset, --- context = args.context, --- request = params, --- response = response, --- })) --- end) --- --- function Source._request(self, params, callback) --- local params = vim.lsp.util.make_position_params() --- if self.request_ids['textDocument/completion'] ~= nil then --- self.client.cancel_request(self.request_ids['textDocument/completion']) --- self.request_ids['textDocument/completion'] = nil --- end --- --- local _, request_id --- _, request_id = self.client.request('textDocument/completion', params, function(arg1, arg2, arg3, arg4) --- print("hello1") --- if self.request_ids['textDocument/completion'] ~= request_id then --- return --- end --- print("hello2") --- end) --- self.request_ids['textDocument/completion'] = request_id --- end --- diff --git a/.config/nvim/lua/plugins.lua b/.config/nvim/lua/plugins.lua index 0ddd090..c9a4452 100644 --- a/.config/nvim/lua/plugins.lua +++ b/.config/nvim/lua/plugins.lua @@ -12,18 +12,18 @@ end local packer_bootstrap = ensure_packer() -- Use a protected call so we don't error out on first use -local status_ok, packer = pcall(require, "packer") +local status_ok, packer = pcall(require, 'packer') if not status_ok then - return + return end -- Have packer use a popup window packer.init({ - display = { - open_fn = function() - return require("packer.util").float({ border = "rounded" }) - end, - }, + display = { + open_fn = function() + return require('packer.util').float({ border = 'rounded' }) + end, + }, }) @@ -39,7 +39,7 @@ packer.startup(function(use) use { 'marko-cerovac/material.nvim', config = function() - vim.g.material_style = "palenight" + vim.g.material_style = 'palenight' vim.cmd [[colorscheme material]] end } @@ -57,12 +57,36 @@ packer.startup(function(use) use { 'neovim/nvim-lspconfig', config = function() - local rt = require("rust-tools") - local capabilities = require("cmp_nvim_lsp").default_capabilities() - local on_attach = function(_, bufnr) - show_hints = false + local rt = require('rust-tools') + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local border = { + {"🭽", "FloatBorder"}, + {"▔", "FloatBorder"}, + {"🭾", "FloatBorder"}, + {"▕", "FloatBorder"}, + {"🭿", "FloatBorder"}, + {"▁", "FloatBorder"}, + {"🭼", "FloatBorder"}, + {"▏", "FloatBorder"}, + } - toggle_hints = function() + local handlers = { + ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {border = border}), + ["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {border = border }), + } + + local on_attach = function(_, bufnr) + show_diagnostics = true + local toggle_diagnostics = function() + if show_diagnostics then + vim.diagnostic.enable() + else + vim.diagnostic.disable() + end + show_diagnostics = not show_diagnostics + end + show_hints = false + local toggle_hints = function() if show_hints then rt.inlay_hints.enable() else @@ -70,10 +94,12 @@ packer.startup(function(use) end show_hints = not show_hints end + vim.diagnostic.config { - float = { border = "rounded" }, + float = { border = 'rounded' }, } - vim.keymap.set("n", "ti", toggle_hints) + vim.keymap.set('n', 'te', toggle_diagnostics) + vim.keymap.set('n', 'ti', toggle_hints) vim.diagnostic.config({ virtual_text = true, signs = true, @@ -81,11 +107,10 @@ packer.startup(function(use) update_in_insert = false, severity_sort = false, }) - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions + local bufopts = { noremap = true, silent = true, buffer = bufnr } - vim.keymap.set("n", "", rt.hover_actions.hover_actions, { buffer = bufnr }) - vim.keymap.set("n", "a", rt.code_action_group.code_action_group, { buffer = bufnr }) + vim.keymap.set('n', '', rt.hover_actions.hover_actions, { buffer = bufnr }) + vim.keymap.set('n', 'a', rt.code_action_group.code_action_group, { buffer = bufnr }) vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts) vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts) vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts) @@ -106,11 +131,15 @@ packer.startup(function(use) vim.keymap.set('n', 'ee', vim.diagnostic.open_float, opts) vim.keymap.set('n', '', vim.diagnostic.goto_prev, opts) vim.keymap.set('n', '', vim.diagnostic.goto_next, opts) + + rt.inlay_hints.disable() + vim.diagnostic.disable() end rt.setup({ server = { on_attach = on_attach, - capabilities = capabilities + capabilities = capabilities, + handlers = handlers }, }) end @@ -119,13 +148,26 @@ packer.startup(function(use) use 'hrsh7th/cmp-buffer' use 'hrsh7th/cmp-path' use 'hrsh7th/cmp-cmdline' + use 'hrsh7th/cmp-nvim-lua' + use 'hrsh7th/cmp-nvim-lsp-signature-help' + use 'saadparwaiz1/cmp_luasnip' + use 'L3MON4D3/LuaSnip' use { 'hrsh7th/nvim-cmp', config = function() local cmp = require('cmp') cmp.setup({ - completion = { - autocomplete = false + view = { + entries = {name = 'wildmenu', separator = '|' } + }, + snippet = { + expand = function(args) + require'luasnip'.lsp_expand(args.body) + end + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), }, mapping = cmp.mapping.preset.insert({ [''] = cmp.mapping.scroll_docs(-4), @@ -135,6 +177,8 @@ packer.startup(function(use) [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), sources = cmp.config.sources({ + { name = 'nvim_lsp_signature_help' }, + { name = 'nvim_lua' }, { name = 'nvim_lsp' }, { name = 'buffer' }, { name = 'path' }, @@ -149,26 +193,19 @@ packer.startup(function(use) use { 'simrat39/rust-tools.nvim' } - use { - 'WhoIsSethDaniel/toggle-lsp-diagnostics.nvim', - config = function() - require'toggle_lsp_diagnostics'.init() - vim.keymap.set('n', 'te', vim.cmd.ToggleDiag) - end - } use { 'j-hui/fidget.nvim', after = 'rust-tools.nvim', config = function() - require("fidget").setup({}) + require('fidget').setup({}) end } use 'mfussenegger/nvim-dap' use { - "rcarriga/nvim-dap-ui", - requires = {"mfussenegger/nvim-dap"}, + 'rcarriga/nvim-dap-ui', + requires = {'mfussenegger/nvim-dap'}, config = function() - require("dapui").setup() + require('dapui').setup() end, } use 'mbbill/undotree' @@ -183,16 +220,30 @@ packer.startup(function(use) end } use { - "kylechui/nvim-surround", - tag = "*", -- Use for stability; omit to use `main` branch for the latest features + 'kylechui/nvim-surround', + tag = '*', -- Use for stability; omit to use `main` branch for the latest features config = function() - require("nvim-surround").setup({}) + require('nvim-surround').setup({}) end } use { 'm4xshen/autoclose.nvim', config = function() - require("autoclose").setup({}) + require('autoclose').setup({}) + end + } + use { + 'ggandor/leap.nvim', + config = function() + require('leap').add_default_mappings() + end + } + use { + "folke/zen-mode.nvim", + config = function() + require("zen-mode").setup { + vim.keymap.set('n', 'tz', vim.cmd.ZenMode) + } end } -- use { 'TimUntersberger/neogit', requires = 'nvim-lua/plenary.nvim' } @@ -208,7 +259,7 @@ local augroup = vim.api.nvim_create_augroup autocmd(('BufWritePost'), { group = augroup('packer_user_config', { clear = true }), - pattern = "plugins.lua", + pattern = 'plugins.lua', once = true, callback = function() vim.cmd('source ~/.config/nvim/lua/plugins.lua')