From 6f75f4e339d4d7449305764cbdeed15c721daae8 Mon Sep 17 00:00:00 2001 From: surtur Date: Tue, 16 Aug 2022 14:03:51 +0200 Subject: [PATCH] systemd,vimrc: add,use gopls daemon --- .config/systemd/user/gopls.service | 31 ++++++++++++++++++++++++++++++ .vim/vimrc | 4 +++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 .config/systemd/user/gopls.service diff --git a/.config/systemd/user/gopls.service b/.config/systemd/user/gopls.service new file mode 100644 index 0000000..af8385d --- /dev/null +++ b/.config/systemd/user/gopls.service @@ -0,0 +1,31 @@ +[Unit] +Description = Go language server. + +[Service] +ExecStartPre=bash -c "rm -v -f /tmp/.gopls-daemon.sock || true" +ExecStart=%h/utils/go/bin/gopls -listen="unix;/tmp/.gopls-daemon.sock" +ExecStopPost=bash -c "rm -v -f /tmp/.gopls-daemon.sock || true" +; -remote.listen.timeout +Restart=on-failure +RestartSec=1m + +SystemCallFilter=~@reboot @obsolete + +ProtectProc=invisible +ProcSubset=pid +ProtectHome=true + +RestrictNamespaces=true + +NoNewPrivileges=yes +ProtectSystem=strict +DevicePolicy=closed +LockPersonality=true +MemoryDenyWriteExecute=true +RestrictAddressFamilies=AF_UNIX +RestrictRealtime=true +RestrictSUIDSGID=true +SystemCallArchitectures=native + +[Install] +WantedBy=default.target \ No newline at end of file diff --git a/.vim/vimrc b/.vim/vimrc index 5281db7..a9978b4 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -498,6 +498,8 @@ let g:go_fmt_command='gopls' let g:go_fmt_autosave = 1 " go install mvdan.cc/gofumpt@latest let g:go_gopls_gofumpt=1 +" let lsp handle connecting to gopls +let g:go_gopls_enabled = 0 augroup vimgo au! @@ -681,7 +683,7 @@ if executable('gopls') autocmd! autocmd User lsp_setup call lsp#register_server({ \ 'name': 'gopls', - \ 'cmd': ['gopls'], + \ 'cmd': ['gopls', '-remote=unix;/tmp/.gopls-daemon.sock'], \ 'allowlist': ['go', 'gomod', 'gosum','gotexttmpl','gohtmltmpl'], \ 'gofumpt': 'true', \ })