all repos — dotfiles @ 574e24bff08a2fb100f24cca387205bdf60d9a9c

linux dotfiles

config/nvim/init.lua (view raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
require 'plugins'
require 'options'
require 'keymaps'
require 'completion'
require 'lsp'
require 'highlights'
require 'snippets'
require 'jq'

-- TODO move each plugin setup to own file
local function nvim_tree_on_attach(bufnr)
  local api = require('nvim-tree.api')
  local function opts(desc)
    return { desc = 'nvim-tree: ' .. desc, buffer = bufnr, noremap = true, silent = true, nowait = true }
  end
  api.config.mappings.default_on_attach(bufnr)
  vim.keymap.set('n', 't', api.node.open.tab, opts('Open: New Tab'))
  vim.keymap.set('n', '<C-s>', api.node.open.horizontal, opts('Open: Horizontal Split'))
end


-- TODO implement min-width option
local tree_width_ratio = 0.3
local tree_height_ratio = 0.82014 

require("nvim-tree").setup({
  on_attach = nvim_tree_on_attach,
  sort_by = "case_sensitive",
  update_focused_file = {
    enable = true,
  },
  view = {
    centralize_selection = true,
    signcolumn = "auto",
    float = {
      enable = true,
      quit_on_focus_loss = true,
      open_win_config = function()
        local screen_w = vim.opt.columns:get()
        local screen_h = vim.opt.lines:get() - vim.opt.cmdheight:get()
        local window_w = screen_w * tree_width_ratio
        local window_h = screen_h * tree_height_ratio
        local window_w_int = math.floor(window_w)
        local window_h_int = math.floor(window_h)
        local center_x = (screen_w - window_w) / 2
        local center_y = ((vim.opt.lines:get() - window_h) / 2)
                         - vim.opt.cmdheight:get()
        return {
          border = "rounded",
          relative = "editor",
          row = center_y,
          col = center_x,
          width = window_w_int,
          height = window_h_int,
        }
        end,
    },
    width = function()
      return math.floor(vim.opt.columns:get() * tree_width_ratio)
    end,
  },
  filters = {
    custom = {"__pycache__"}
  },
  diagnostics = {
    enable = true
  },
  actions = {
    open_file = {
      window_picker = {
        enable = false
      },
    },
  },
  renderer = {
    indent_markers = {
      enable = false 
    },
    icons = {
      show = {
        file = false,
        folder = false,
      },
      git_placement = "before",
      glyphs = {
        git = {
          unstaged = "△",
          staged = "✔",
          unmerged = "",
          renamed = "➜",
          untracked = "★",
          deleted = "✗",
          ignored = "◌",
        }
      }
    }
  },
})


require('telescope').setup {
  defaults = {
    mappings = {
      i = {
        ['<Esc>'] = require('telescope.actions').close,
        ['<C-j>'] = require('telescope.actions').move_selection_next,
        ['<C-k>'] = require('telescope.actions').move_selection_previous,
      }
    },
  },
  pickers = {
    find_files = {
      previewer = false,
      layout_config = {
        width = {0.5, max=80, min=60}
      }
    },
    buffers = {
      previewer = false,
      layout_config = {
        width = {0.5, max=80, min=60}
      }
    },
  },
  extensions = {
    fzf = {
      fuzzy = true,                    -- false will only do exact matching
      override_generic_sorter = true,
      override_file_sorter = true,
      case_mode = "smart_case",        -- or "ignore_case" or "respect_case"
                                       -- the default case_mode is "smart_case"
    }
  }
}

require("symbols-outline").setup()

require('gitblame').setup {
     --Note how the `gitblame_` prefix is omitted in `setup`
    enabled = false,
}

require('telescope').load_extension('fzf')

-- require'nvim-treesitter.configs'.setup {
--   ensure_installed = { "python", "hcl", "json", "go", "lua", "javascript", "typescript", "html", "css", "c", "cpp", "rust" },
--   sync_install = false,
--   auto_install = true,
--   -- ignore_install = { "javascript" },
--   highlight = {
--     enable = true,
--     disable = { "help"},

--     -- Setting this to true will run `:h syntax` and tree-sitter at the same time.
--     -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
--     -- Using this option may slow down your editor, and you may see some duplicate highlights.
--     -- Instead of true it can also be a list of languages
--     additional_vim_regex_highlighting = true,
--   },
--   indent = {
--     enable = false,
--     disable = {"hcl", "python"}
--   }
-- }

-- Test runner options
vim.cmd('let test#strategy = "neovim_sticky"')
vim.cmd('let test#neovim#term_position = "vert botright"')

-- TODO move to seperate autocmd file
vim.cmd ([[
  autocmd FileType html,javascript,lua,typescript,yaml setlocal ts=2 sts=2 sw=2
  autocmd FileType hcl setlocal ts=2 sts=2 sw=2
  autocmd BufRead  *jsx setlocal sw=2
  autocmd BufRead  *tsx setlocal sw=2
  autocmd FileType markdown setlocal spell
]])