2021-07-11 15:06:37 -07:00
|
|
|
local execute = vim.api.nvim_command
|
|
|
|
local fn = vim.fn
|
|
|
|
|
2021-07-15 08:19:22 -07:00
|
|
|
local install_path = fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
local function load_plugins()
|
|
|
|
local use = require('packer').use
|
|
|
|
require('packer').startup(function()
|
2021-07-15 08:19:22 -07:00
|
|
|
use 'wbthomason/packer.nvim' -- Package manager
|
2021-07-15 22:19:17 -07:00
|
|
|
use 'neovim/nvim-lspconfig' -- Collection of configurations for built-in LSP client
|
2021-07-11 15:06:37 -07:00
|
|
|
use 'nvim-treesitter/nvim-treesitter'
|
2021-07-14 23:28:30 -07:00
|
|
|
use 'nvim-treesitter/nvim-treesitter-textobjects'
|
2021-07-15 22:19:17 -07:00
|
|
|
use 'nvim-treesitter/playground'
|
2021-07-11 15:06:37 -07:00
|
|
|
use 'folke/which-key.nvim'
|
2021-07-15 22:19:17 -07:00
|
|
|
use 'folke/lua-dev.nvim'
|
2021-07-15 08:19:22 -07:00
|
|
|
use 'folke/tokyonight.nvim' -- Theme
|
2021-07-15 22:19:17 -07:00
|
|
|
use { 'folke/trouble.nvim', requires = 'kyazdani42/nvim-web-devicons' }
|
|
|
|
use { 'nvim-telescope/telescope.nvim', requires = { { 'nvim-lua/popup.nvim' }, { 'nvim-lua/plenary.nvim' } } }
|
2021-07-15 08:19:22 -07:00
|
|
|
use 'windwp/nvim-autopairs' -- Autopairs
|
2021-07-11 15:06:37 -07:00
|
|
|
use 'kyazdani42/nvim-tree.lua' -- File explorer
|
2021-07-15 08:19:22 -07:00
|
|
|
use {
|
|
|
|
'glepnir/galaxyline.nvim',
|
|
|
|
config = function()
|
|
|
|
require 'salargalaxyline'
|
|
|
|
end,
|
|
|
|
requires = 'kyazdani42/nvim-web-devicons',
|
|
|
|
}
|
2021-07-11 15:06:37 -07:00
|
|
|
use 'lukas-reineke/indent-blankline.nvim'
|
2021-07-11 15:25:20 -07:00
|
|
|
use { 'lewis6991/gitsigns.nvim', requires = 'nvim-lua/plenary.nvim' }
|
2021-07-15 08:19:22 -07:00
|
|
|
use { 'TimUntersberger/neogit', requires = { { 'nvim-lua/plenary.nvim' }, { 'sindrets/diffview.nvim' } } }
|
|
|
|
use { 'hrsh7th/nvim-compe', requires = 'L3MON4D3/LuaSnip' } -- Autocompletion plugin
|
2021-07-11 15:06:37 -07:00
|
|
|
use 'kevinhwang91/nvim-bqf'
|
|
|
|
use 'mfussenegger/nvim-dap'
|
|
|
|
use 'sheerun/vim-polyglot'
|
|
|
|
use 'scalameta/nvim-metals'
|
2021-07-14 08:43:08 -07:00
|
|
|
use 'ray-x/lsp_signature.nvim'
|
2021-07-15 07:48:18 -07:00
|
|
|
use 'b3nj5m1n/kommentary'
|
2021-07-15 08:19:22 -07:00
|
|
|
use 'ckipp01/stylua-nvim'
|
2021-07-15 22:19:17 -07:00
|
|
|
use 'gennaro-tedesco/nvim-jqx'
|
2021-07-16 08:08:29 -07:00
|
|
|
use 'kristijanhusak/orgmode.nvim'
|
2021-07-20 21:16:57 -07:00
|
|
|
use 'p00f/nvim-ts-rainbow'
|
2021-07-11 15:06:37 -07:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
|
|
|
_G.load_config = function()
|
2021-07-11 22:50:49 -07:00
|
|
|
require('gitsigns').setup()
|
2021-07-15 07:48:18 -07:00
|
|
|
require('kommentary.config').use_extended_mappings()
|
2021-07-16 08:08:29 -07:00
|
|
|
require('nvim-autopairs').setup()
|
|
|
|
require 'salargalaxyline'
|
|
|
|
require('trouble').setup()
|
|
|
|
require('which-key').setup()
|
2021-07-15 07:48:18 -07:00
|
|
|
|
2021-07-15 22:19:17 -07:00
|
|
|
local luadev = require('lua-dev').setup()
|
|
|
|
|
2021-07-16 08:08:29 -07:00
|
|
|
-- orgmode.nvim
|
|
|
|
require('orgmode').setup({
|
|
|
|
org_agenda_files = {'~/Documents/org'},
|
|
|
|
org_default_notes_file = '~/Documents/org/notes.org'
|
|
|
|
})
|
|
|
|
|
2021-07-11 15:06:37 -07:00
|
|
|
-- Treesitter
|
2021-07-14 23:28:30 -07:00
|
|
|
require('nvim-treesitter.configs').setup {
|
2021-07-11 15:06:37 -07:00
|
|
|
query_linter = {
|
|
|
|
enable = true,
|
|
|
|
use_virtual_text = true,
|
2021-07-15 08:19:22 -07:00
|
|
|
lint_events = { 'BufWrite', 'CursorHold' },
|
2021-07-11 15:06:37 -07:00
|
|
|
},
|
2021-07-15 08:19:22 -07:00
|
|
|
ensure_installed = 'maintained',
|
2021-07-11 15:06:37 -07:00
|
|
|
highlight = { enable = true },
|
2021-07-14 23:28:30 -07:00
|
|
|
incremental_selection = {
|
|
|
|
enable = true,
|
|
|
|
keymaps = {
|
|
|
|
init_selection = 'gnn',
|
|
|
|
node_incremental = 'grn',
|
|
|
|
scope_incremental = 'grc',
|
|
|
|
node_decremental = 'grm',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
indent = {
|
|
|
|
enable = true,
|
|
|
|
},
|
|
|
|
textobjects = {
|
|
|
|
select = {
|
|
|
|
enable = true,
|
|
|
|
lookahead = true, -- Automatically jump forward to textobj, similar to targets.vim
|
|
|
|
keymaps = {
|
|
|
|
-- You can use the capture groups defined in textobjects.scm
|
|
|
|
['af'] = '@function.outer',
|
|
|
|
['if'] = '@function.inner',
|
|
|
|
['ac'] = '@class.outer',
|
|
|
|
['ic'] = '@class.inner',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
move = {
|
|
|
|
enable = true,
|
|
|
|
set_jumps = true, -- whether to set jumps in the jumplist
|
|
|
|
goto_next_start = {
|
|
|
|
[']m'] = '@function.outer',
|
|
|
|
[']]'] = '@class.outer',
|
|
|
|
},
|
|
|
|
goto_next_end = {
|
|
|
|
[']M'] = '@function.outer',
|
|
|
|
[']['] = '@class.outer',
|
|
|
|
},
|
|
|
|
goto_previous_start = {
|
|
|
|
['[m'] = '@function.outer',
|
|
|
|
['[['] = '@class.outer',
|
|
|
|
},
|
|
|
|
goto_previous_end = {
|
|
|
|
['[M'] = '@function.outer',
|
|
|
|
['[]'] = '@class.outer',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
playground = {
|
|
|
|
enable = true,
|
|
|
|
disable = {},
|
|
|
|
updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code
|
|
|
|
persist_queries = false, -- Whether the query persists across vim sessions
|
|
|
|
keybindings = {
|
|
|
|
toggle_query_editor = 'o',
|
|
|
|
toggle_hl_groups = 'i',
|
|
|
|
toggle_injected_languages = 't',
|
|
|
|
toggle_anonymous_nodes = 'a',
|
|
|
|
toggle_language_display = 'I',
|
|
|
|
focus_language = 'f',
|
|
|
|
unfocus_language = 'F',
|
|
|
|
update = 'R',
|
|
|
|
goto_node = '<cr>',
|
|
|
|
show_help = '?',
|
|
|
|
},
|
2021-07-15 08:19:22 -07:00
|
|
|
},
|
2021-07-20 21:16:57 -07:00
|
|
|
rainbow = {
|
|
|
|
enable = true,
|
|
|
|
extended_mode = true,
|
|
|
|
max_file_lines = 1000,
|
|
|
|
},
|
2021-07-14 23:28:30 -07:00
|
|
|
}
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
-- neogit
|
2021-07-15 08:19:22 -07:00
|
|
|
require('neogit').setup {
|
2021-07-11 15:06:37 -07:00
|
|
|
integrations = {
|
2021-07-15 08:19:22 -07:00
|
|
|
diffview = true,
|
|
|
|
},
|
|
|
|
}
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Incremental live completion
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.o.inccommand = 'nosplit'
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Set highlight on search
|
|
|
|
vim.o.hlsearch = false
|
|
|
|
vim.o.incsearch = true
|
|
|
|
|
|
|
|
--Make line numbers default
|
|
|
|
vim.wo.number = true
|
|
|
|
|
|
|
|
--Do not save when switching buffers
|
|
|
|
vim.o.hidden = true
|
|
|
|
|
|
|
|
--Enable mouse mode
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.o.mouse = 'a'
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
-- clipboard
|
|
|
|
vim.o.clipboard = 'unnamedplus'
|
|
|
|
|
|
|
|
--Enable break indent
|
|
|
|
vim.o.breakindent = true
|
|
|
|
|
|
|
|
--Save undo history
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.cmd [[set undofile]]
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Case insensitive searching UNLESS /C or capital in search
|
|
|
|
vim.o.ignorecase = true
|
|
|
|
vim.o.smartcase = true
|
|
|
|
|
|
|
|
--Decrease update time
|
|
|
|
vim.o.updatetime = 250
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.wo.signcolumn = 'yes'
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Set colorscheme (order is important here)
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.g.tokyonight_style = 'night'
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.g.tokyonight_italic_functions = true
|
|
|
|
vim.o.termguicolors = true
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.cmd [[colorscheme tokyonight]]
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Remap space as leader key
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_set_keymap('', '<Space>', '<Nop>', { noremap = true, silent = true })
|
|
|
|
vim.g.mapleader = ' '
|
|
|
|
vim.g.maplocalleader = ' '
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Remap for dealing with word wrap
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_set_keymap('n', 'k', "v:count == 0 ? 'gk' : 'k'", { noremap = true, expr = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', 'j', "v:count == 0 ? 'gj' : 'j'", { noremap = true, expr = true, silent = true })
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Remap escape to leave terminal mode
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_set_keymap('t', '<Esc>', [[<c-\><c-n>]], { noremap = true })
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Add map to enter paste mode
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.o.pastetoggle = '<F3>'
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
--Map blankline
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.g.indent_blankline_char = '┊'
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.g.indent_blankline_filetype_exclude = { 'help', 'packer' }
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.g.indent_blankline_buftype_exclude = { 'terminal', 'nofile' }
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.g.indent_blankline_char_highlight = 'LineNr'
|
|
|
|
|
|
|
|
-- Toggle to disable mouse mode and indentlines for easier paste
|
|
|
|
ToggleMouse = function()
|
|
|
|
if vim.o.mouse == 'a' then
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.cmd [[IndentBlanklineDisable]]
|
|
|
|
vim.wo.signcolumn = 'no'
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.o.mouse = 'v'
|
|
|
|
vim.wo.number = false
|
2021-07-15 08:19:22 -07:00
|
|
|
print 'Mouse disabled'
|
2021-07-11 15:06:37 -07:00
|
|
|
else
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.cmd [[IndentBlanklineEnable]]
|
|
|
|
vim.wo.signcolumn = 'yes'
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.o.mouse = 'a'
|
|
|
|
vim.wo.number = true
|
2021-07-15 08:19:22 -07:00
|
|
|
print 'Mouse enabled'
|
2021-07-11 15:06:37 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
vim.api.nvim_set_keymap('n', '<F10>', '<cmd>lua ToggleMouse()<cr>', { noremap = true })
|
|
|
|
|
|
|
|
-- Telescope
|
|
|
|
require('telescope').setup {
|
|
|
|
defaults = {
|
|
|
|
mappings = {
|
|
|
|
i = {
|
2021-07-15 08:19:22 -07:00
|
|
|
['<C-u>'] = false,
|
|
|
|
['<C-d>'] = false,
|
2021-07-11 15:06:37 -07:00
|
|
|
},
|
|
|
|
},
|
2021-07-15 08:19:22 -07:00
|
|
|
generic_sorter = require('telescope.sorters').get_fzy_sorter,
|
|
|
|
file_sorter = require('telescope.sorters').get_fzy_sorter,
|
|
|
|
},
|
2021-07-11 15:06:37 -07:00
|
|
|
}
|
|
|
|
--Add leader shortcuts
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_set_keymap('n', '<leader>f', [[<cmd>lua require('telescope.builtin').find_files()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader><space>', [[<cmd>lua require('telescope.builtin').buffers()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>l', [[<cmd>lua require('telescope.builtin').current_buffer_fuzzy_find()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>t', [[<cmd>lua require('telescope.builtin').tags()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>?', [[<cmd>lua require('telescope.builtin').oldfiles()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>sd', [[<cmd>lua require('telescope.builtin').grep_string()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>sp', [[<cmd>lua require('telescope.builtin').live_grep()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>o', [[<cmd>lua require('telescope.builtin').tags{ only_current_buffer = true }<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>gc', [[<cmd>lua require('telescope.builtin').git_commits()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>gb', [[<cmd>lua require('telescope.builtin').git_branches()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>gs', [[<cmd>lua require('telescope.builtin').git_status()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>gp', [[<cmd>lua require('telescope.builtin').git_bcommits()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>m', [[<cmd>lua require('nvim-tree').toggle()<cr>]], { noremap = true, silent = true })
|
|
|
|
vim.api.nvim_set_keymap('n', '<leader>ng', [[<cmd>lua require('neogit').open({ kind = "split" })<cr>]], { noremap = true, silent = true })
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.api.nvim_set_keymap('n', '<leader>nu', ':PackerUpdate<CR>', { noremap = true, silent = true })
|
|
|
|
|
|
|
|
-- Change preview window location
|
|
|
|
vim.g.splitbelow = true
|
|
|
|
|
|
|
|
-- Highlight on yank
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_exec(
|
|
|
|
[[
|
2021-07-11 15:06:37 -07:00
|
|
|
augroup YankHighlight
|
|
|
|
autocmd!
|
|
|
|
autocmd TextYankPost * silent! lua vim.highlight.on_yank()
|
|
|
|
augroup end
|
2021-07-15 08:19:22 -07:00
|
|
|
]],
|
|
|
|
false
|
|
|
|
)
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
-- Y yank until the end of line
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_set_keymap('n', 'Y', 'y$', { noremap = true })
|
2021-07-11 15:06:37 -07:00
|
|
|
--
|
|
|
|
-- LSP settings
|
2021-07-15 08:19:22 -07:00
|
|
|
local nvim_lsp = require 'lspconfig'
|
2021-07-11 15:06:37 -07:00
|
|
|
local on_attach = function(_client, bufnr)
|
2021-07-14 08:43:08 -07:00
|
|
|
require('lsp_signature').on_attach()
|
|
|
|
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
|
2021-07-15 08:19:22 -07:00
|
|
|
local opts = { noremap = true, silent = true }
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<Cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<Cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<Cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gm', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>e', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[d', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']d', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts)
|
|
|
|
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<leader>q', '<cmd>lua vim.lsp.diagnostic.set_loclist()<CR>', opts)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Enable the following language servers
|
2021-07-15 08:19:22 -07:00
|
|
|
local servers = { 'jdtls', 'pyright', 'rnix', 'sourcekit' }
|
2021-07-11 15:06:37 -07:00
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
nvim_lsp[lsp].setup { on_attach = on_attach }
|
|
|
|
end
|
|
|
|
|
2021-07-15 08:19:22 -07:00
|
|
|
-- lua language server
|
|
|
|
local sumneko_binary = vim.fn.getenv 'HOME' .. '/.nix-profile/bin/lua-language-server'
|
|
|
|
local runtime_path = vim.split(package.path, ';')
|
|
|
|
table.insert(runtime_path, 'lua/?.lua')
|
|
|
|
table.insert(runtime_path, 'lua/?/init.lua')
|
|
|
|
|
|
|
|
require('lspconfig').sumneko_lua.setup {
|
|
|
|
cmd = { sumneko_binary },
|
|
|
|
commands = {
|
|
|
|
Format = {
|
|
|
|
function()
|
|
|
|
require('stylua-nvim').format_file()
|
|
|
|
end,
|
2021-07-11 22:50:49 -07:00
|
|
|
},
|
2021-07-15 08:19:22 -07:00
|
|
|
},
|
|
|
|
on_attach = on_attach,
|
|
|
|
settings = {
|
|
|
|
Lua = {
|
|
|
|
runtime = {
|
|
|
|
-- Tell the language server which version of Lua you're using (most likely LuaJIT in the case of Neovim)
|
|
|
|
version = 'LuaJIT',
|
|
|
|
-- Setup your lua path
|
|
|
|
path = runtime_path,
|
|
|
|
},
|
|
|
|
diagnostics = {
|
|
|
|
-- Get the language server to recognize the `vim` global
|
|
|
|
globals = { 'vim' },
|
|
|
|
},
|
|
|
|
workspace = {
|
|
|
|
-- Make the server aware of Neovim runtime files
|
2021-07-15 22:19:17 -07:00
|
|
|
library = {
|
|
|
|
vim.api.nvim_get_runtime_file('', true),
|
|
|
|
luadev,
|
|
|
|
},
|
2021-07-15 08:19:22 -07:00
|
|
|
},
|
|
|
|
-- Do not send telemetry data containing a randomized but unique identifier
|
|
|
|
telemetry = {
|
|
|
|
enable = false,
|
|
|
|
},
|
2021-07-11 22:50:49 -07:00
|
|
|
},
|
|
|
|
},
|
2021-07-15 08:19:22 -07:00
|
|
|
}
|
2021-07-11 22:50:49 -07:00
|
|
|
|
2021-07-11 15:06:37 -07:00
|
|
|
-- metals
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.opt_global.shortmess:remove('F'):append 'c'
|
2021-07-22 23:38:39 -07:00
|
|
|
Metals_config = require('metals').bare_config
|
|
|
|
Metals_config.init_options.statusBarProvider = 'on'
|
2021-07-11 15:06:37 -07:00
|
|
|
vim.cmd [[augroup lsp]]
|
|
|
|
vim.cmd [[au!]]
|
|
|
|
vim.cmd [[au FileType scala,sbt lua require("metals").initialize_or_attach(metals_config)]]
|
|
|
|
vim.cmd [[augroup end]]
|
|
|
|
|
|
|
|
-- Map :Format to vim.lsp.buf.formatting()
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.cmd [[ command! Format execute 'lua vim.lsp.buf.formatting()' ]]
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
-- Set completeopt to have a better completion experience
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.o.completeopt = 'menuone,noinsert'
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
-- Compe setup
|
2021-07-15 08:19:22 -07:00
|
|
|
require('compe').setup {
|
|
|
|
enabled = true,
|
|
|
|
autocomplete = true,
|
|
|
|
debug = false,
|
|
|
|
min_length = 1,
|
|
|
|
preselect = 'enable',
|
|
|
|
throttle_time = 80,
|
|
|
|
source_timeout = 200,
|
|
|
|
incomplete_delay = 400,
|
|
|
|
max_abbr_width = 100,
|
|
|
|
max_kind_width = 100,
|
|
|
|
max_menu_width = 100,
|
|
|
|
documentation = true,
|
2021-07-11 15:06:37 -07:00
|
|
|
|
|
|
|
source = {
|
2021-07-15 08:19:22 -07:00
|
|
|
path = true,
|
2021-07-11 15:06:37 -07:00
|
|
|
nvim_lsp = {
|
|
|
|
priority = 1000,
|
2021-07-22 23:38:39 -07:00
|
|
|
filetypes = { 'scala', 'sbt', 'java', 'python' },
|
2021-07-11 15:06:37 -07:00
|
|
|
},
|
|
|
|
nvim_lua = true,
|
|
|
|
buffer = true,
|
|
|
|
luasnip = true,
|
2021-07-16 08:08:29 -07:00
|
|
|
orgmode = true,
|
2021-07-15 08:19:22 -07:00
|
|
|
},
|
2021-07-11 15:06:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
local t = function(str)
|
|
|
|
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
local check_back_space = function()
|
2021-07-15 08:19:22 -07:00
|
|
|
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
|
2021-07-11 15:06:37 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Use (s-)tab to:
|
|
|
|
--- move to prev/next item in completion menuone
|
|
|
|
--- jump to prev/next snippet's placeholder
|
|
|
|
_G.tab_complete = function()
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
2021-07-15 08:19:22 -07:00
|
|
|
return t '<C-n>'
|
2021-07-11 15:06:37 -07:00
|
|
|
elseif check_back_space() then
|
2021-07-15 08:19:22 -07:00
|
|
|
return t '<Tab>'
|
2021-07-11 15:06:37 -07:00
|
|
|
else
|
|
|
|
return vim.fn['compe#complete']()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
_G.s_tab_complete = function()
|
|
|
|
if vim.fn.pumvisible() == 1 then
|
2021-07-15 08:19:22 -07:00
|
|
|
return t '<C-p>'
|
2021-07-11 15:06:37 -07:00
|
|
|
else
|
2021-07-15 08:19:22 -07:00
|
|
|
return t '<S-Tab>'
|
2021-07-11 15:06:37 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-07-15 08:19:22 -07:00
|
|
|
vim.api.nvim_set_keymap('i', '<Tab>', 'v:lua.tab_complete()', { expr = true })
|
|
|
|
vim.api.nvim_set_keymap('s', '<Tab>', 'v:lua.tab_complete()', { expr = true })
|
|
|
|
vim.api.nvim_set_keymap('i', '<S-Tab>', 'v:lua.s_tab_complete()', { expr = true })
|
|
|
|
vim.api.nvim_set_keymap('s', '<S-Tab>', 'v:lua.s_tab_complete()', { expr = true })
|
2021-07-11 15:06:37 -07:00
|
|
|
end
|
|
|
|
|
|
|
|
if fn.isdirectory(install_path) == 0 then
|
2021-07-15 08:19:22 -07:00
|
|
|
fn.system { 'git', 'clone', 'https://github.com/wbthomason/packer.nvim', install_path }
|
2021-07-11 15:06:37 -07:00
|
|
|
load_plugins()
|
|
|
|
require('packer').sync()
|
|
|
|
vim.cmd 'autocmd User PackerComplete ++once lua load_config()'
|
|
|
|
else
|
|
|
|
load_plugins()
|
|
|
|
_G.load_config()
|
|
|
|
end
|