Skip to content

Commit

Permalink
feat(coding): install and configure go toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
massix committed Apr 21, 2024
1 parent 14f13b4 commit 3b16b0c
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -149,4 +149,6 @@
the following languages are supported (with ~LSP~ where available):
- ~C~, ~C++~ and derivates
- ~Javascript~ and ~Typescript~
- =typst= for document writing
- =go= with =delve= debugger

3 changes: 3 additions & 0 deletions coding/install_coding.fish
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ check_install cppcheck cppcheck
check_install npm nodejs
check_install typst typst
check_install typst-lsp typst-lsp
check_install go golang
check_install gopls gopls
check_install dlv delve
check_install_npm yaml-language-server yaml-language-server
check_install_npm vscode-json-language-server vscode-langservers-extracted
check_install_npm bash-language-server bash-language-server
3 changes: 3 additions & 0 deletions fish/config.fish
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ if status is-interactive
set -x PAGER bat
set -x EDITOR nvim
set -x LEDGER_FILE "$HOME/org/.hledger.journal"

# Add go path
test -d {$HOME}/go/bin; and fish_add_path --path {$HOME}/go/bin
end
1 change: 1 addition & 0 deletions nvim/lua/plugins/coding.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ return {
lua = { "stylua" },
fish = { "fish_indent" },
c = { "clang_format" },
go = { "gofmt" },
},
format_on_save = function(_)
return { lsp_fallback = true }
Expand Down
14 changes: 14 additions & 0 deletions nvim/lua/plugins/dap.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-- Debug adapters for NeoVim
local json_transforms = {
["lldb"] = { "c", "cpp" },
["delve"] = { "go" },
}

--- @type LazyPluginSpec[]
Expand Down Expand Up @@ -106,6 +107,19 @@ return {
name = "lldb",
}

dap.adapters.delve = {
type = "server",
port = "${port}",
executable = {
command = "dlv",
args = { "dap", "--only-same-user=false", "-l", "127.0.0.1:${port}" },
detached = true,
},
options = {
initialize_timeout_sec = 20,
},
}

-- setup dap config by VsCode launch.json file
require("dap.ext.vscode").load_launchjs(nil, json_transforms)
end,
Expand Down
5 changes: 5 additions & 0 deletions nvim/lua/plugins/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ return {
capabilities = capabilities,
on_attach = attach_trouble,
})

lspconfig.gopls.setup({
capabilities = capabilities,
on_attach = attach_trouble,
})
end,
},

Expand Down
1 change: 1 addition & 0 deletions nvim/lua/plugins/treesitter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ return {
"dockerfile",
"elvish",
"fish",
"go",
"haskell",
"hjson",
"html",
Expand Down
19 changes: 17 additions & 2 deletions scripts/library.fish
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,30 @@ function check_install -a cmd pkg
end

function check_install_npm -a cmd pkg
if ! type -q npm then
if ! type -q npm
error "You must install npm first"
return
end

if ! type -q $cmd then
if ! type -q $cmd
info "Installing $pkg from npm"
npm i -g $pkg
else
info "$cmd from npm $pkg already installed"
end
end

function check_install_go -a binary gopkg --description "Install a Go Package"
if ! type -q go
error "You must install go first"
return
end

set -l GO_BIN_PATH {$HOME}/go/bin
if ! type -q $binary and ! test -f {$GO_BIN_PATH}/$binary
info "Installing $binary from $gopkg in $GO_BIN_PATH"
go install $gopkg
else
info "$binary (gopkg $gopkg) already installed"
end
end

0 comments on commit 3b16b0c

Please sign in to comment.