146 lines
3.7 KiB
Lua
146 lines
3.7 KiB
Lua
-- prevent cursor override
|
|
-- vim.cmd('set guicursor=')
|
|
vim.opt.guicursor = ""
|
|
vim.cmd('let g:do_filetype_lua=1')
|
|
|
|
-- basic settings
|
|
vim.cmd('filetype plugin indent on')
|
|
vim.cmd('set ts=4 sts=4 sw=4 expandtab')
|
|
|
|
-- clipboard
|
|
vim.cmd('set clipboard+=unnamedplus')
|
|
|
|
-- hybrid numbering
|
|
vim.opt.relativenumber = true
|
|
vim.opt.number = true
|
|
vim.opt.cursorline = true
|
|
|
|
vim.opt.compatible = false
|
|
|
|
-- ignores search case unless capital is used
|
|
vim.opt.smartcase = true
|
|
vim.opt.hlsearch = true
|
|
|
|
-- timeouts
|
|
vim.opt.ttimeout = true
|
|
vim.opt.ttimeoutlen = 100
|
|
vim.o.updatetime = 250
|
|
|
|
-- nvim tree basics
|
|
|
|
vim.g.loaded_netrw = 1
|
|
vim.g.loaded_netrwPlugin = 1
|
|
|
|
-- vimwiki changes
|
|
vim.cmd([[
|
|
let g:vimwiki_list = [{'path': '~/vimwiki/',
|
|
\ 'syntax': 'markdown', 'ext':'.md'}]
|
|
]])
|
|
|
|
-- go file settings
|
|
vim.g.go_hightlight_types = 1
|
|
vim.g.go_hightlight_fields = 1
|
|
vim.g.go_hightlight_functions = 1
|
|
vim.g.go_hightlight_function_calls = 1
|
|
vim.g.go_hightlight_operators = 1
|
|
vim.g.go_hightlight_extra_types = 1
|
|
|
|
-- airline settings
|
|
if vim.g.airline_symbols == nil then
|
|
vim.g.airline_symbols = vim.empty_dict()
|
|
end
|
|
|
|
vim.g.airline_powerline_fonts = 1
|
|
vim.g.airline_symbols.linenr = ''
|
|
vim.g.airline_symbols.maxlinenr = ''
|
|
vim.g.airline_symbols.dirty = ''
|
|
|
|
-- vimtex settings
|
|
vim.g.vimtex_view_method = 'zathura'
|
|
vim.cmd([[
|
|
let g:vimtex_quickfix_ignore_filters = [
|
|
\ 'Citation',
|
|
\ 'Font Warning',
|
|
\]
|
|
]])
|
|
|
|
-- sets autocommands for bufenters etc -> NOT DOING pattern should be faster?
|
|
-- calcurse -> markdown
|
|
-- vim.api.nvim_create_autocmd({"BufRead","BufNewFile"}, {
|
|
-- pattern = {"/tmp/calcurse*","~/.local/share/calcurse/notes/*"},
|
|
-- command = "set filetype=markdown",
|
|
-- })
|
|
|
|
-- sets fileypes for those that are not auto recognized
|
|
-- sway config
|
|
vim.filetype.add({
|
|
pattern = {
|
|
['.*/sway/.*'] = 'swayconfig',
|
|
},
|
|
})
|
|
|
|
-- calcurse notes as markdown
|
|
vim.filetype.add({
|
|
pattern = {
|
|
['/tmp/calcurse.*;.*/calcurse/notes/.*'] = 'markdown',
|
|
},
|
|
})
|
|
|
|
-- markdown settings
|
|
vim.opt.conceallevel = 2
|
|
vim.g.vim_markdown_folding_disabled = 1
|
|
vim.g.vim_markdown_math = 1
|
|
vim.g.vim_markdown_strikethrough = 1
|
|
|
|
-- custom TODO highlighting
|
|
-- vim.cmd("syntax on")
|
|
vim.cmd("highlight default link MyTodo Todo")
|
|
-- vim.cmd([[silent! syntax clear MyTodo]])
|
|
--
|
|
-- -- Tag keywords anywhere (including comments/strings)
|
|
-- vim.cmd([[
|
|
-- syntax match MyTodo /\v<(TODO|FIXME|NOTE|HACK|BUG)>/ containedin=ALL
|
|
-- highlight default link MyTodo Todo
|
|
-- ]])
|
|
|
|
-- Custom go file template when opening empty file
|
|
-- vim.api.nvim_create_autocmd("BufNewFile", {
|
|
-- pattern = "*.go",
|
|
-- callback = function()
|
|
-- -- Only insert if the file is empty
|
|
-- if vim.fn.line("$") == 1 and vim.fn.getline(1) == "" then
|
|
-- vim.api.nvim_buf_set_lines(0, 0, -1, false, {
|
|
-- "package main",
|
|
-- "",
|
|
-- "func main() {",
|
|
-- "\t",
|
|
-- "}",
|
|
-- "",
|
|
-- })
|
|
-- vim.api.nvim_win_set_cursor(0, {4, 2}) -- place cursor inside main
|
|
-- end
|
|
-- end,
|
|
-- })
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
pattern = "*.go",
|
|
callback = function()
|
|
-- 1) Organize imports (gopls code action)
|
|
local params = vim.lsp.util.make_range_params()
|
|
params.context = { only = { "source.organizeImports" } }
|
|
|
|
local result = vim.lsp.buf_request_sync(0, "textDocument/codeAction", params, 3000)
|
|
for _, res in pairs(result or {}) do
|
|
for _, action in pairs(res.result or {}) do
|
|
if action.edit then
|
|
vim.lsp.util.apply_workspace_edit(action.edit, "utf-8")
|
|
elseif action.command then
|
|
vim.lsp.buf.execute_command(action.command)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- 2) Format (gopls formatting)
|
|
vim.lsp.buf.format({ async = false })
|
|
end,
|
|
})
|