From 4385c252eb461a0ec9dbf9569a8f9ef7f0664289 Mon Sep 17 00:00:00 2001 From: Michaël Ball Date: Tue, 16 Jul 2024 16:12:12 +0100 Subject: Initial commit --- neovim/.config/nvim/lua/settings.lua | 150 +++++++++++++++++++++++++++++++++++ 1 file changed, 150 insertions(+) create mode 100644 neovim/.config/nvim/lua/settings.lua (limited to 'neovim/.config/nvim/lua/settings.lua') diff --git a/neovim/.config/nvim/lua/settings.lua b/neovim/.config/nvim/lua/settings.lua new file mode 100644 index 0000000..7afe46f --- /dev/null +++ b/neovim/.config/nvim/lua/settings.lua @@ -0,0 +1,150 @@ +require('config.colourscheme') +-- General settings + +vim.g.loaded_python_provider = 1 +vim.g.python3_host_prog = '/Users/michael/.pyenv/shims/python3' +vim.g.loaded_perl_provider = 0 +vim.g.loaded_ruby_provider = 0 + +vim.opt.rnu = true +vim.opt.number = true +vim.opt.hlsearch = true +vim.opt.incsearch = true +vim.opt.backspace = { 'indent', 'eol', 'start' } +vim.opt.visualbell = true +vim.opt.clipboard:append { 'unnamedplus' } +vim.opt.completeopt = { 'menuone', 'noselect' } +vim.opt.cmdheight = 0 +vim.opt.expandtab = true +vim.opt.wrap = false +vim.opt.shiftwidth = 4 +vim.opt.softtabstop = 4 +vim.opt.smarttab = true +vim.opt.encoding = 'utf-8' +vim.opt.foldenable = false +vim.opt.linebreak = true +vim.opt.showbreak = '↪ ' +vim.opt.breakindent = true +vim.opt.termguicolors = true +vim.cmd[[ +syntax on + filetype on + filetype plugin on + filetype plugin indent on + highlight Comment cterm=italic gui=italic +]] +vim.opt.backup = false +vim.opt.writebackup = false +vim.opt.updatetime = 300 +vim.opt.shortmess:append 'c' +vim.opt.signcolumn = 'yes' + +vim.keymap.set("", "", "tabprevious", { noremap=true }) +vim.keymap.set("", "", "tabnext", { noremap=true }) + +-- Autocommands + +local indent_rules_augroup = vim.api.nvim_create_augroup('Indents', {}) +vim.api.nvim_create_autocmd( { 'FileType' }, { + pattern = { 'make', 'sh' }, + group = indent_rules_augroup, + callback = function() + vim.opt_local.tabstop = 8 + vim.opt_local.shiftwidth = 8 + vim.opt_local.softtabstop = 0 + vim.opt_local.expandtab = false + end +}) +vim.api.nvim_create_autocmd( { 'FileType' }, { + pattern = { 'go' }, + group = indent_rules_augroup, + callback = function() + vim.opt_local.tabstop = 4 + vim.opt_local.shiftwidth = 4 + vim.opt_local.softtabstop = 0 + vim.opt_local.expandtab = false + end +}) +vim.api.nvim_create_autocmd( { 'FileType' }, { + pattern = { 'javascript', 'lua' }, + group = indent_rules_augroup, + callback = function() + vim.opt_local.tabstop = 2 + vim.opt_local.shiftwidth = 2 + vim.opt_local.softtabstop = 2 + end +}) + +local wrap_rules_augroup = vim.api.nvim_create_augroup('Wrap', {}) +vim.api.nvim_create_autocmd( { 'FileType' }, { + pattern = { 'markdown', 'rst', 'text' }, + group = wrap_rules_augroup, + callback = function() + vim.opt_local.wrap = true + end +}) + +local terminal_rules_augroup = vim.api.nvim_create_augroup('Terminal', {}) +vim.api.nvim_create_autocmd( { 'TermOpen' }, { + pattern = { '*' }, + group = terminal_rules_augroup, + callback = function() + vim.cmd('startinsert') + vim.opt_local.scrollback = 100000 + vim.opt_local.modified = true + vim.opt_local.bufhidden = 'hide' + vim.opt_local.statusline = vim.api.nvim_buf_get_var(0, 'term_title') + vim.opt_local.number = false + vim.opt_local.rnu = false + vim.cmd('match Errormsg ""') + end +}) + +-- Terminal +vim.cmd[[ + tnoremap + tnoremap h + tnoremap j + tnoremap k + tnoremap l + inoremap h + inoremap j + inoremap k + inoremap l + nnoremap h + nnoremap j + nnoremap k + nnoremap l + + let g:term_buf = 0 + let g:term_win = 0 + + function! Term_toggle(height) + if win_gotoid(g:term_win) + hide + else + botright new + exec "resize ". a:height + try + exec "buffer " . g:term_buf + catch + call termopen($SHELL, {"detach": 0}) + keepalt file Terminal + let g:term_buf = bufnr("") + endtry + let g:term_win = win_getid() + endif + endfunction + + nnoremap t :call Term_toggle(15) +]] + +-- Tab navigation in gui +if vim.fn.has('gui_running') == 1 then + vim.keymap.set('n', '', 'tabp', { noremap = true, silent = true }) + vim.keymap.set('v', '', 'tabp', { noremap = true, silent = true }) + vim.keymap.set('i', '', 'tabp', { noremap = true, silent = true }) + vim.keymap.set('n', '', 'tabn', { noremap = true, silent = true }) + vim.keymap.set('v', '', 'tabn', { noremap = true, silent = true }) + vim.keymap.set('i', '', 'tabn', { noremap = true, silent = true }) +end -- cgit v1.2.3