diff --git a/README.org b/README.org index ffef8d3..18139f3 100644 --- a/README.org +++ b/README.org @@ -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 diff --git a/coding/install_coding.fish b/coding/install_coding.fish index f279203..c95b6ad 100755 --- a/coding/install_coding.fish +++ b/coding/install_coding.fish @@ -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 diff --git a/fish/config.fish b/fish/config.fish index 1897ac1..2796cc5 100644 --- a/fish/config.fish +++ b/fish/config.fish @@ -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 diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index 3c08037..a1ac6ae 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -35,6 +35,7 @@ return { lua = { "stylua" }, fish = { "fish_indent" }, c = { "clang_format" }, + go = { "gofmt" }, }, format_on_save = function(_) return { lsp_fallback = true } diff --git a/nvim/lua/plugins/dap.lua b/nvim/lua/plugins/dap.lua index 46dfc4d..9c3804d 100644 --- a/nvim/lua/plugins/dap.lua +++ b/nvim/lua/plugins/dap.lua @@ -1,6 +1,7 @@ -- Debug adapters for NeoVim local json_transforms = { ["lldb"] = { "c", "cpp" }, + ["delve"] = { "go" }, } --- @type LazyPluginSpec[] @@ -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, diff --git a/nvim/lua/plugins/lsp.lua b/nvim/lua/plugins/lsp.lua index fcfeb68..fb99f8e 100644 --- a/nvim/lua/plugins/lsp.lua +++ b/nvim/lua/plugins/lsp.lua @@ -156,6 +156,11 @@ return { capabilities = capabilities, on_attach = attach_trouble, }) + + lspconfig.gopls.setup({ + capabilities = capabilities, + on_attach = attach_trouble, + }) end, }, diff --git a/nvim/lua/plugins/treesitter.lua b/nvim/lua/plugins/treesitter.lua index fd32a1d..f1ddce1 100644 --- a/nvim/lua/plugins/treesitter.lua +++ b/nvim/lua/plugins/treesitter.lua @@ -33,6 +33,7 @@ return { "dockerfile", "elvish", "fish", + "go", "haskell", "hjson", "html", diff --git a/scripts/library.fish b/scripts/library.fish index 90fa315..f139b02 100644 --- a/scripts/library.fish +++ b/scripts/library.fish @@ -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