~keving/dotfiles

32f11f4895aa169310154f113cd524f96e80ec68 — Kevin Guillaumond 1 year, 3 months ago 59af462
Add some missing autocmd features back, comment out broken config
M .config/nvim/init.lua => .config/nvim/init.lua +19 -22
@@ 66,8 66,8 @@ cmd [[ let NERDTreeIgnore=['\.pyc$', '\~$'] ]]
-- Automatically close NERDTree when you open a file
g['NERDTreeQuitOnOpen'] = 1

-- Automatically close a tab if the only remaining window is NERDTree (TODO)
-- autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
-- Automatically close a tab if the only remaining window is NERDTree
vim.cmd('autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif')

-- Automatically delete the buffer of the file you just deleted with NerdTree:
g['NERDTreeAutoDeleteBuffer'] = 1


@@ 99,7 99,7 @@ utils.map('n', '<leader>l', ':SyntasticCheck<CR>', {silent = true})

-- Telescope
-- Shortcut for 'go to buffer'
utils.map('n', 'gb', ':Telescope buffers<CR>') 
utils.map('n', 'gb', ':Telescope buffers<CR>')
utils.map('n', '<leader>ff', ':Telescope find_files<CR>')




@@ 169,7 169,7 @@ cmd 'set whichwrap+=<,>,h,l'

-- Search
vim.o.ignorecase = true -- Ignore case when searching
vim.o.smartcase = true  -- When searching try to be smart about cases 
vim.o.smartcase = true  -- When searching try to be smart about cases

-- Stop highlighting last search pattern
utils.map('n', '<leader><cr>', ':noh<cr>', {silent = true})


@@ 204,7 204,7 @@ vim.o.fileformats = 'unix,dos,mac'
vim.o.expandtab = true

-- 1 tab == 2 spaces
local indent = 2 
local indent = 2
vim.o.shiftwidth = indent
vim.o.tabstop = indent -- Number of visual spaces per TAB
vim.o.softtabstop = indent -- Number of spaces per TAB when editing


@@ 261,13 261,12 @@ utils.map('n', '<leader>te', ':tabedit <c-r>=expand("%:p:h")<cr>/')
-- Switch CWD to the directory of the open buffer
utils.map('n', '<leader>cd', ':cd %:p:h<cr>:pwd<cr>')

-- Specify the behavior when switching between buffers 
-- Specify the behavior when switching between buffers
vim.o.switchbuf = 'useopen,usetab,newtab'
vim.o.showtabline = 1

-- Return to last edit position when opening files
-- TODO
-- au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
vim.cmd([[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif]])


-- Editing mappings


@@ 280,16 279,15 @@ utils.map('n', 'x', '"_x')
utils.map('n', 'X', '"_X')

-- Delete trailing white space on save
-- TODO
-- fun! CleanExtraSpaces()
--     let save_cursor = getpos(".")
--     let old_query = getreg('/')
--     silent! %s/\s\+$//e
--     call setpos('.', save_cursor)
--     call setreg('/', old_query)
-- endfun
function clean_extra_spaces()
  local save_cursor = vim.fn.getpos(".")
  local old_query = vim.fn.getreg("/")
  vim.cmd([[silent! %s/\s\+$//e]])
  vim.fn.setpos('.', save_cursor)
  vim.fn.setreg('/', old_query)
end

-- autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
vim.cmd('autocmd BufWritePre *.txt,*.js,*.py,*.c,*.sh,*.lua :lua clean_extra_spaces()')


-- Code


@@ 305,10 303,9 @@ utils.map('n', '<space>', 'za')
utils.map('n', '<C-]>', 'g<C-]>')

-- Ruby autocomplete
-- TODO
-- autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1 
-- autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1
-- autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
vim.cmd('autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1')
vim.cmd('autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1')
vim.cmd('autocmd FileType ruby,eruby let g:rubycomplete_rails = 1')

-- Run tests
-- Using ,tj because ,tn is used by tabs


@@ 377,7 374,7 @@ function! CmdLine(str)
    exe "menu Foo.Bar :" . a:str
    emenu Foo.Bar
    unmenu Foo
endfunction 
endfunction

function! VisualSelection(direction, extra_filter) range
    let l:saved_reg = @"

M .config/nvim/lua/plugin_configs/nvim-lspconfig.lua => .config/nvim/lua/plugin_configs/nvim-lspconfig.lua +9 -9
@@ 12,15 12,15 @@ utils.map('n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', {silent = true}) -- TODO


-- TODO Map K to this so it shows vim documentation first
vim.api.nvim_exec([[
function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  else
    call <cmd>lua vim.lsp.buf.hover()<CR>
  endif
endfunction
]], false)
-- vim.api.nvim_exec([[
-- function! s:show_documentation()
--   if (index(['vim','help'], &filetype) >= 0)
--     execute 'h '.expand('<cword>')
--   else
--     call <cmd>lua vim.lsp.buf.hover()<CR>
--   endif
-- endfunction
-- ]], false)

-- Disable LSP diagnostics for now
vim.lsp.handlers['textDocument/publishDiagnostics'] = function() end

M .config/nvim/lua/utils.lua => .config/nvim/lua/utils.lua +6 -6
@@ 6,12 6,12 @@ function utils.t(str)
end

function utils.check_back_space()
    local col = vim.fn.col('.') - 1
    if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
        return true
    else
        return false
    end
  local col = vim.fn.col('.') - 1
  if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
    return true
  else
    return false
  end
end

local scopes = { o = vim.o, b = vim.bo, w = vim.wo }