Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Last active April 6, 2024 22:33
Show Gist options
  • Save yordanoweb/6fa3e620cc0acb6287db9b0360656916 to your computer and use it in GitHub Desktop.
Save yordanoweb/6fa3e620cc0acb6287db9b0360656916 to your computer and use it in GitHub Desktop.

LUA config with some helpers for LunarVim

local lspconfig = require('lspconfig')

-- Detect if in a Go project
local function is_go_project()
  local go_files = vim.fn.globpath(vim.fn.getcwd(), '*.go', true, true)
  local go_mod_file = vim.fn.findfile('go.mod', vim.fn.getcwd())

  return #go_files > 0 or go_mod_file ~= ''
end

-- Launch gopls for Go projects
if is_go_project() then
  lspconfig.gopls.setup{}
end

vim.cmd([[
  augroup golang_tabwidth
    autocmd!
    autocmd FileType go setlocal tabstop=7 shiftwidth=7
  augroup END
  let g:go_fmt_command = "golines"
  let g:go_fmt_command = {
    \ 'golines': '-m 80',
    \ }
  set rnu
  set cc=80
]])

vim.keymap.set('n', '<A-Right>', '<CMD>BufferLineMoveNext<CR>')
vim.keymap.set('n', '<A-Left>', '<CMD>BufferLineMovePrev<CR>')
vim.keymap.set('n', '<C-s>', '<CMD>mksession! .session.vim<CR>')
vim.keymap.set('n', '<C-M-s>', '<CMD>source .session.vim<CR>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment