From 660ff7d94d22962b8227b96ef9b2f0760c9929cc Mon Sep 17 00:00:00 2001 From: Michael Housh Date: Sun, 1 Oct 2023 11:28:24 -0400 Subject: [PATCH] Added go.nvim, updated ts script to accept a session argument --- nvim/m-housh/lazy-lock.json | 12 +++++++----- nvim/m-housh/lua/user/autocmd.lua | 11 +++++++++++ nvim/m-housh/lua/user/mappings.lua | 2 ++ nvim/m-housh/lua/user/plugin/cmp.lua | 4 ++-- nvim/m-housh/lua/user/plugin/go.lua | 15 +++++++++++++++ nvim/m-housh/lua/user/plugin/lsp.lua | 3 ++- nvim/m-housh/lua/user/plugins.lua | 1 + scripts/scripts/ts | 14 ++++++++++++-- tmux/tmux.conf | 1 - 9 files changed, 52 insertions(+), 11 deletions(-) create mode 100644 nvim/m-housh/lua/user/plugin/go.lua diff --git a/nvim/m-housh/lazy-lock.json b/nvim/m-housh/lazy-lock.json index aaca2db..d319441 100644 --- a/nvim/m-housh/lazy-lock.json +++ b/nvim/m-housh/lazy-lock.json @@ -8,23 +8,25 @@ "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, "cmp-spell": { "branch": "master", "commit": "32a0867efa59b43edbb2db67b0871cfad90c9b66" }, "formatter.nvim": { "branch": "master", "commit": "34dcdfa0c75df667743b2a50dd99c84a557376f0" }, - "lazy.nvim": { "branch": "main", "commit": "6a2c47e6424a3f1e373bfeb714b716f6be13501c" }, + "go.nvim": { "branch": "master", "commit": "2f573a297bea3a483a3607ae7c607a8a08d27993" }, + "guihua.lua": { "branch": "master", "commit": "5ad8dba19ce9b9fd8965598984dfdc9c119f97e4" }, + "lazy.nvim": { "branch": "main", "commit": "59335c5b9d116f5d3948f833288a89e2a829a005" }, "lazygit.nvim": { "branch": "main", "commit": "de35012036d43bca03628d40d083f7c02a4cda3f" }, "lsp_signature.nvim": { "branch": "master", "commit": "bdf3dc7bb03edd25c2173e0e31c2fb122052ed23" }, "lspkind-nvim": { "branch": "master", "commit": "57610d5ab560c073c465d6faf0c19f200cb67e6e" }, "lualine.nvim": { "branch": "master", "commit": "45e27ca739c7be6c49e5496d14fcf45a303c3a63" }, - "mason-lspconfig.nvim": { "branch": "main", "commit": "81e30dd629de24cbb26d08073ee938ab40006695" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "48025d62f45af52ba47e4193b854864839392e4c" }, "mason.nvim": { "branch": "main", "commit": "d66c60e17dd6fd8165194b1d14d21f7eb2c1697a" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "71f1841ba6c652908678cece623f52c1fea8a6cd" }, - "neodev.nvim": { "branch": "main", "commit": "58b1c0740e8ad79ce71e2649a449bb90536435cf" }, + "neodev.nvim": { "branch": "main", "commit": "41581561a0ffc6ea6a191ee90a23f8c1c7f470fb" }, "nightfox.nvim": { "branch": "main", "commit": "fe2fc7b93d66349eff2c5baa6cec922ee3958f56" }, "noice.nvim": { "branch": "main", "commit": "396f9146529130904e07c45e90ecdbfa607534f3" }, "nui.nvim": { "branch": "main", "commit": "c8de23342caf8d50b15d6b28368d36a56a69d76f" }, "nvim-cmp": { "branch": "main", "commit": "5dce1b778b85c717f6614e3f4da45e9f19f54435" }, "nvim-lsp-installer": { "branch": "main", "commit": "17e0bfa5f2c8854d1636fcd036dc8284db136baa" }, - "nvim-lspconfig": { "branch": "master", "commit": "576c8a5987bb276d234dd1d04e6c9fe60da1185d" }, + "nvim-lspconfig": { "branch": "master", "commit": "fabd2578cbce0a76d48afa4b369f27a08f03ead3" }, "nvim-notify": { "branch": "master", "commit": "e4a2022f4fec2d5ebc79afa612f96d8b11c627b3" }, - "nvim-treesitter": { "branch": "master", "commit": "16ea2969ea0a5ba902fceece9b2db10c7c9ba2d6" }, + "nvim-treesitter": { "branch": "master", "commit": "776e4d341b5416c995e74c3abbf75f9cec26aa5e" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "bd103502252027434ec42f628d2dbf54821d4ce6" }, "nvim-web-devicons": { "branch": "master", "commit": "45d0237c427baba8cd05e0ab26d30e2ee58c2c82" }, "plenary.nvim": { "branch": "master", "commit": "9ce85b0f7dcfe5358c0be937ad23e456907d410b" }, diff --git a/nvim/m-housh/lua/user/autocmd.lua b/nvim/m-housh/lua/user/autocmd.lua index 17bdb5d..c6632b0 100644 --- a/nvim/m-housh/lua/user/autocmd.lua +++ b/nvim/m-housh/lua/user/autocmd.lua @@ -34,3 +34,14 @@ vim.api.nvim_create_autocmd( } ) +vim.api.nvim_create_autocmd( + "BufWritePre", + { + pattern = "*.go", + callback = function() + require('go.format').goimport() + end, + group = vim.api.nvim_create_augroup("GoFormat", { clear = true }) + } +) + diff --git a/nvim/m-housh/lua/user/mappings.lua b/nvim/m-housh/lua/user/mappings.lua index 66b721e..72531d1 100644 --- a/nvim/m-housh/lua/user/mappings.lua +++ b/nvim/m-housh/lua/user/mappings.lua @@ -34,6 +34,8 @@ keymap("n", "", ":Neotree toggle", default_options) -- Toggle Lazy Git keymap("n", 'gg', ':LazyGit', default_options) +keymap("n", "gf", ":Telescope git_files", default_options) +keymap("n", "t", ":ToggleTerm", default_options) -- Toggle term key maps, that get attached when terminal is opened. function _G.set_terminal_keymaps() diff --git a/nvim/m-housh/lua/user/plugin/cmp.lua b/nvim/m-housh/lua/user/plugin/cmp.lua index 45ef9cf..8e2dfc7 100644 --- a/nvim/m-housh/lua/user/plugin/cmp.lua +++ b/nvim/m-housh/lua/user/plugin/cmp.lua @@ -95,10 +95,10 @@ return { [""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), - [""] = cmp.mapping.close(), + [""] = cmp.mapping.abort(), [""] = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, - select = false + select = true }, [""] = cmp.mapping(function(fallback) if cmp.visible() then diff --git a/nvim/m-housh/lua/user/plugin/go.lua b/nvim/m-housh/lua/user/plugin/go.lua new file mode 100644 index 0000000..0e29674 --- /dev/null +++ b/nvim/m-housh/lua/user/plugin/go.lua @@ -0,0 +1,15 @@ +return { + "ray-x/go.nvim", + lazy = true, + dependencies = { -- optional packages + "ray-x/guihua.lua", + "neovim/nvim-lspconfig", + "nvim-treesitter/nvim-treesitter", + }, + config = function() + require("go").setup() + end, + event = {"CmdlineEnter"}, + ft = {"go", 'gomod'}, + build = ':lua require("go.install").update_all_sync()' -- if you need to install/update all binaries +} diff --git a/nvim/m-housh/lua/user/plugin/lsp.lua b/nvim/m-housh/lua/user/plugin/lsp.lua index 3a94735..52806f5 100644 --- a/nvim/m-housh/lua/user/plugin/lsp.lua +++ b/nvim/m-housh/lua/user/plugin/lsp.lua @@ -14,7 +14,8 @@ return { "ray-x/lsp_signature.nvim", "neovim/nvim-lspconfig", "folke/neodev.nvim", - "mhartington/formatter.nvim" + "mhartington/formatter.nvim", + "ray-x/go.nvim", }, opts = { ensure_installed = { diff --git a/nvim/m-housh/lua/user/plugins.lua b/nvim/m-housh/lua/user/plugins.lua index bcb6c27..8356256 100644 --- a/nvim/m-housh/lua/user/plugins.lua +++ b/nvim/m-housh/lua/user/plugins.lua @@ -33,6 +33,7 @@ require("lazy").setup({ { import = 'user.plugin.lualine' }, { import = 'user.plugin.treesitter' }, { import = 'user.plugin.formatter' }, + { import = 'user.plugin.go' }, -- Navigation -- { import = 'user.plugin.neo-tree' }, diff --git a/scripts/scripts/ts b/scripts/scripts/ts index 50eac03..2525583 100755 --- a/scripts/scripts/ts +++ b/scripts/scripts/ts @@ -1,4 +1,14 @@ #!/bin/sh -session=$(tmux list-sessions -F \#S | gum filter --placeholder "Pick a session...") -tmux switch-client -t "$session" || tmux attach -t "$session" +session=${1} + +if [ -z "$session" ]; then + session=$(tmux list-sessions -F \#S | gum filter --placeholder "Pick a session...") + tmux switch-client -t "$session" || tmux attach -t "$session" +else + if [ ! -z "$(tmux list-sessions -F \#S | grep $session)" ]; then + tmux switch-client -t "$session" || tmux attach -t "$session" + else + echo "No session found for: $session" + fi +fi diff --git a/tmux/tmux.conf b/tmux/tmux.conf index 4b6fc13..1df933f 100644 --- a/tmux/tmux.conf +++ b/tmux/tmux.conf @@ -64,7 +64,6 @@ bind -T prefix l select-pane -R bind -n S-Left previous-window bind -n S-Right next-window - # reload new changes bind-key R source-file ~/.config/tmux/tmux.conf\; \display-message "source-file done"