~keving/dotfiles

e883d92a7981b4b6c0db2f5237eb9ef955fc14cd — Kevin Guillaumond 2 months ago 54d4cf2
airline -> lualine, rust LSP, global status line in 0.7
2 files changed, 34 insertions(+), 5 deletions(-)

M .config/nvim/init.lua
M .config/nvim/lua/plugin_configs/nvim-lspconfig.lua
M .config/nvim/init.lua => .config/nvim/init.lua +29 -4
@@ 28,7 28,7 @@ require "paq" {
    'nvim-lua/plenary.nvim';   -- Helper for other plugins
    'nvim-telescope/telescope.nvim';
    'morhetz/gruvbox';         -- Color scheme
    'vim-airline/vim-airline'; -- Status line at the bottom
    'nvim-lualine/lualine.nvim'; -- Status line at the bottom
    'mileszs/ack.vim';         -- ack/ag in vim
    'embear/vim-localvimrc';   -- Local vimrc files for project-specific settings
    


@@ 48,7 48,10 @@ require "paq" {
    -- Python
    'numirias/semshi';          -- Syntax highlighting
    'nvie/vim-flake8';          -- Python style checker
    

    -- Rust
    'simrat39/rust-tools.nvim'; -- Nice config for rust_analizer (inlay hints etc)

    -- PlantUML
    'aklt/plantuml-syntax';     -- Syntax highlighting
}


@@ 76,6 79,16 @@ utils.map('n', '<leader>hp', '<cmd>Gitsigns preview_hunk<CR>')
utils.map('n', '<leader>hb', '<cmd>lua require"gitsigns".blame_line{full=true}<CR>')
utils.map('n', '<leader>hp', ':Gitsigns preview_hunk<CR>', {silent = true})


--- Lualine
require('lualine').setup {
  options = {
    globalstatus = true,
    theme  = gruvbox,
  },
}


-- NERDTree
-- Shortcut to open NERDTree
utils.map('n', '<leader>ne', ':NERDTreeToggle<Enter>')


@@ 87,6 100,7 @@ cmd [[ let NERDTreeIgnore=['\.pyc$', '\~$', '\.o', '\.lo'] ]]
g['NERDTreeQuitOnOpen'] = 1

-- Automatically close a tab if the only remaining window is NERDTree
-- TODO in nvim >= 0.7, use nvim_create_autocmd
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:


@@ 234,6 248,11 @@ vim.o.updatetime = 250
-- Add a bit extra margin to the left
vim.o.foldcolumn = '1'

-- Use global statusline
if vim.fn.has 'nvim-0.7' == 1 then
  vim.go.laststatus = 3
end


-- Colors and Fonts
vim.o.cursorline = true


@@ 323,6 342,7 @@ vim.o.switchbuf = 'useopen,usetab,newtab'
vim.o.showtabline = 1

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




@@ 331,8 351,10 @@ vim.cmd([[autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") |
--

-- Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
-- which is the default
utils.map('n', 'Y', 'y$')
-- which was the default until 0.6
if vim.fn.has 'nvim-0.6' == 0 then
  utils.map('n', 'Y', 'y$')
end

-- Don't write to yank buffer when deleting a single character
utils.map('n', 'x', '"_x')


@@ 347,6 369,7 @@ function clean_extra_spaces()
  vim.fn.setreg('/', old_query)
end

-- TODO in nvim >= 0.7, use nvim_create_autocmd
vim.cmd('autocmd BufWritePre *.txt,*.js,*.py,*.sh,*.lua :lua clean_extra_spaces()')




@@ 366,6 389,7 @@ utils.map('n', '<space>', 'za')
utils.map('n', '<C-]>', 'g<C-]>')

-- Ruby autocomplete
-- TODO in nvim >= 0.7, use nvim_create_autocmd
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')


@@ 516,3 540,4 @@ utils.nvim_create_augroups(augroup_defs)
-- TODO
-- Rewrite usages of cmd and nvim_exec in Lua
-- Tidy code with plugin-specific config to its own files, like https://github.com/ibhagwan/nvim-lua
-- Use nvim_create_autocmd in 0.7

M .config/nvim/lua/plugin_configs/nvim-lspconfig.lua => .config/nvim/lua/plugin_configs/nvim-lspconfig.lua +5 -1
@@ 16,7 16,11 @@ require'lspconfig'.clangd.setup{
require'lspconfig'.pyright.setup{
  filetypes = {'python'},
}
require'lspconfig'.rls.setup{}  -- TODO use rust-analizer
if vim.fn.has 'nvim-0.7' == 1 then
  require'rust-tools'.setup{};
else
  require'lspconfig'.rust_analyzer.setup{}
end


local opts = { noremap=true, silent=true }