2022-07-25 14:59:32 +00:00
|
|
|
local opt = vim.opt
|
|
|
|
local g = vim.g
|
|
|
|
|
|
|
|
vim.cmd [[
|
2022-08-07 15:46:39 +00:00
|
|
|
colorscheme onehalflight
|
2022-08-01 21:11:10 +00:00
|
|
|
|
|
|
|
if has("autocmd")
|
|
|
|
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
|
|
|
endif
|
2022-08-07 13:23:23 +00:00
|
|
|
|
|
|
|
autocmd Filetype json
|
|
|
|
\ let g:indentLine_setConceal = 0 |
|
|
|
|
\ let g:vim_json_syntax_conceal = 0
|
2022-07-25 14:59:32 +00:00
|
|
|
]]
|
|
|
|
|
|
|
|
g.mapleader = ' '
|
2022-08-07 20:44:58 +00:00
|
|
|
g.indentLine_char = '⎸'
|
|
|
|
g.indentLine_color_gui = '#c7c7c7'
|
2022-07-25 14:59:32 +00:00
|
|
|
|
|
|
|
opt.undofile = true
|
|
|
|
opt.undodir = "/home/sijmen/.cache/nvim/undo"
|
|
|
|
opt.backupdir = "/home/sijmen/.cache/nvim/backup"
|
|
|
|
|
|
|
|
opt.smartindent = true
|
|
|
|
opt.autoindent = true
|
|
|
|
opt.tabstop = 2
|
|
|
|
opt.shiftwidth = 2
|
|
|
|
opt.expandtab = true
|
|
|
|
|
|
|
|
opt.mouse = "a"
|
|
|
|
|
|
|
|
opt.termguicolors = true
|
|
|
|
opt.cursorline = true
|
|
|
|
opt.relativenumber = true
|
2022-08-20 13:33:34 +00:00
|
|
|
opt.number = true
|
2022-07-25 14:59:32 +00:00
|
|
|
|
|
|
|
opt.smartcase = true
|
|
|
|
opt.ttimeoutlen = 5
|
|
|
|
opt.compatible = false
|
|
|
|
opt.autoread = true
|
|
|
|
opt.incsearch = true
|
|
|
|
opt.hidden = true
|
|
|
|
opt.shortmess = "atI"
|
|
|
|
|
2022-08-01 21:11:10 +00:00
|
|
|
|
2022-07-25 14:59:32 +00:00
|
|
|
require("nvim-tree").setup()
|
|
|
|
|
2022-08-07 21:00:08 +00:00
|
|
|
require("lualine").setup {
|
|
|
|
options = {
|
|
|
|
component_separators = { left = "", right = "" },
|
|
|
|
section_separators = { left = "", right = "" },
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-07-25 14:59:32 +00:00
|
|
|
require("nvim-treesitter.configs").setup {
|
|
|
|
auto_install = true,
|
2022-09-05 22:15:53 +00:00
|
|
|
highlight = { enable = true },
|
|
|
|
parser_install_dir = "/home/sijmen/.cache/nvim/treesitter",
|
2022-07-25 14:59:32 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 22:15:53 +00:00
|
|
|
vim.opt.runtimepath:append("/home/sijmen/.cache/nvim/treesitter")
|
|
|
|
|
2022-08-01 21:11:10 +00:00
|
|
|
|
2022-08-07 20:44:58 +00:00
|
|
|
local opts = { noremap=true, silent=true }
|
|
|
|
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
|
|
|
|
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
|
|
|
|
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
|
|
|
|
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|
|
|
|
|
|
|
local on_attach = function(client, bufnr)
|
|
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
|
|
|
|
local bufopts = { noremap=true, silent=true, buffer=bufnr }
|
|
|
|
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
|
|
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
|
|
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
|
|
|
|
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
|
|
|
|
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
|
2022-08-05 11:29:18 +00:00
|
|
|
|
2022-08-07 20:44:58 +00:00
|
|
|
vim.keymap.set('n', '<space>wl', function()
|
|
|
|
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
|
|
|
|
end, bufopts)
|
|
|
|
|
|
|
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
|
|
|
|
vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
|
|
|
|
vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
|
|
|
|
end
|
|
|
|
|
2022-08-12 00:14:31 +00:00
|
|
|
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
capabilities = require("cmp_nvim_lsp").update_capabilities(capabilities)
|
|
|
|
|
2022-08-07 20:44:58 +00:00
|
|
|
local lspconfig = require("lspconfig")
|
2022-08-12 00:14:31 +00:00
|
|
|
local servers = { "rnix", "pyright", "rust_analyzer" }
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
|
|
lspconfig[lsp].setup {
|
|
|
|
on_attach = on_attach,
|
|
|
|
capabilities = capabilities,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
local luasnip = require("luasnip")
|
|
|
|
|
|
|
|
local cmp = require("cmp")
|
|
|
|
cmp.setup {
|
|
|
|
snippet = {
|
|
|
|
expand = function(args)
|
|
|
|
luasnip.lsp_expand(args.body)
|
|
|
|
end,
|
|
|
|
},
|
|
|
|
mapping = cmp.mapping.preset.insert({
|
|
|
|
["<C-d>"] = cmp.mapping.scroll_docs(-4),
|
|
|
|
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
|
|
|
["<C-Space>"] = cmp.mapping.complete(),
|
|
|
|
["<CR>"] = cmp.mapping.confirm {
|
|
|
|
behavior = cmp.ConfirmBehavior.Replace,
|
|
|
|
select = true,
|
|
|
|
},
|
|
|
|
["<Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_next_item()
|
|
|
|
elseif luasnip.expand_or_jumpable() then
|
|
|
|
luasnip.expand_or_jump()
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
["<S-Tab>"] = cmp.mapping(function(fallback)
|
|
|
|
if cmp.visible() then
|
|
|
|
cmp.select_prev_item()
|
|
|
|
elseif luasnip.jumpable(-1) then
|
|
|
|
luasnip.jump(-1)
|
|
|
|
else
|
|
|
|
fallback()
|
|
|
|
end
|
|
|
|
end, { "i", "s" }),
|
|
|
|
}),
|
|
|
|
sources = {
|
|
|
|
{ name = "nvim_lsp" },
|
|
|
|
{ name = "luasnip" },
|
|
|
|
},
|
|
|
|
}
|
2022-08-05 11:29:18 +00:00
|
|
|
|
|
|
|
vim.api.nvim_set_keymap("n", "<C-b>", ":NvimTreeToggle<CR>", { noremap = true, silent = true })
|