summaryrefslogtreecommitdiff
path: root/neovim/.config/nvim/lua/settings.lua
diff options
context:
space:
mode:
authorMichaël Ball <michael@Michaels-MacBook-Pro.local>2024-07-16 16:12:12 +0100
committerMichaël Ball <michael@Michaels-MacBook-Pro.local>2024-07-16 16:12:12 +0100
commit4385c252eb461a0ec9dbf9569a8f9ef7f0664289 (patch)
treede1005fbc0274eea549dc42ca5be17101b937463 /neovim/.config/nvim/lua/settings.lua
Initial commit
Diffstat (limited to 'neovim/.config/nvim/lua/settings.lua')
-rw-r--r--neovim/.config/nvim/lua/settings.lua150
1 files changed, 150 insertions, 0 deletions
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("", "<A-{>", "<cmd>tabprevious<CR>", { noremap=true })
+vim.keymap.set("", "<A-}>", "<cmd>tabnext<CR>", { 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 <Esc> <C-\><C-n>
+ tnoremap <A-h> <C-\><C-N><C-w>h
+ tnoremap <A-j> <C-\><C-N><C-w>j
+ tnoremap <A-k> <C-\><C-N><C-w>k
+ tnoremap <A-l> <C-\><C-N><C-w>l
+ inoremap <A-h> <C-\><C-N><C-w>h
+ inoremap <A-j> <C-\><C-N><C-w>j
+ inoremap <A-k> <C-\><C-N><C-w>k
+ inoremap <A-l> <C-\><C-N><C-w>l
+ nnoremap <A-h> <C-w>h
+ nnoremap <A-j> <C-w>j
+ nnoremap <A-k> <C-w>k
+ nnoremap <A-l> <C-w>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 <Leader>t :call Term_toggle(15)<CR>
+]]
+
+-- Tab navigation in gui
+if vim.fn.has('gui_running') == 1 then
+ vim.keymap.set('n', '<A-{>', '<cmd>tabp<CR>', { noremap = true, silent = true })
+ vim.keymap.set('v', '<A-{>', '<cmd>tabp<CR>', { noremap = true, silent = true })
+ vim.keymap.set('i', '<A-{>', '<Esc><cmd>tabp<CR>', { noremap = true, silent = true })
+ vim.keymap.set('n', '<A-}>', '<cmd>tabn<CR>', { noremap = true, silent = true })
+ vim.keymap.set('v', '<A-}>', '<cmd>tabn<CR>', { noremap = true, silent = true })
+ vim.keymap.set('i', '<A-}>', '<Esc><cmd>tabn<CR>', { noremap = true, silent = true })
+end