You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
344 lines
11 KiB
344 lines
11 KiB
-- some basic options
|
|
local vim = vim
|
|
vim.opt.tabstop = 4
|
|
vim.opt.shiftwidth = 4
|
|
vim.opt.softtabstop = 2
|
|
vim.opt.expandtab = true
|
|
vim.opt.termguicolors = true
|
|
vim.opt.autoindent = true
|
|
vim.opt.smartindent = true
|
|
vim.opt.smarttab = true
|
|
vim.opt.number = true
|
|
vim.o.hidden = true
|
|
vim.o.signcolumn = 'auto'
|
|
vim.o.breakindent = true
|
|
vim.o.smarttab = true
|
|
vim.o.errorbells = true
|
|
vim.o.clipboard = "unnamedplus"
|
|
vim.g.noswapfile = true
|
|
vim.cmd [[set mouse=a]] -- enable mouse
|
|
vim.wo.cursorline = true
|
|
vim.opt.hlsearch = false
|
|
vim.opt.wrap = true
|
|
vim.opt.showmatch = true
|
|
|
|
vim.g.python3_host_prog = '/home/frosty/.dotfiles/nvim/env/bin/python'
|
|
|
|
vim.api.nvim_create_user_command('W', 'write', {})
|
|
|
|
vim.opt.foldmethod = "expr"
|
|
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
|
|
|
|
-- hit zc to enable folding
|
|
vim.o.foldenable = false
|
|
|
|
vim.g.neomake_open_list = 2
|
|
|
|
function map(mode, shortcut, command)
|
|
vim.api.nvim_set_keymap(mode, shortcut, command, { noremap = true, silent = true })
|
|
end
|
|
|
|
-- normal mode map
|
|
function nmap(shortcut, command)
|
|
map('n', shortcut, command)
|
|
end
|
|
|
|
-- insert mode map
|
|
function imap(shortcut, command)
|
|
map('i', shortcut, command)
|
|
end
|
|
|
|
vim.opt.guifont = "Iosevka Nerd Font:h12"
|
|
if vim.g.neovide then
|
|
vim.g.neovide_refresh_rate = 140
|
|
-- change to whatever font you prefer
|
|
-- can check font with fc-cache on linux
|
|
vim.g.neovide_hide_mouse_when_typing = true
|
|
vim.g.neovide_refresh_rate_idle = 140
|
|
vim.g.neovide_scale_factor = 1.0
|
|
-- zoom with CTRL - and CTRL +
|
|
local change_scale_factor = function(delta)
|
|
vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * delta
|
|
end
|
|
vim.keymap.set("n", "<C-=>", function()
|
|
change_scale_factor(1.25)
|
|
end)
|
|
vim.keymap.set("n", "<C-->", function()
|
|
change_scale_factor(1 / 1.25)
|
|
end)
|
|
end
|
|
|
|
|
|
-- <leader> is leader key; default is \
|
|
nmap("<leader>v", "<cmd>NvimTreeToggle<cr>")
|
|
nmap("<leader>ec", "<cmd>e ~/.config/nvim/init.lua<cr>")
|
|
nmap("<leader>sc", "<cmd>source ~/.config/nvim/init.lua<cr>")
|
|
|
|
-- buffer commands
|
|
nmap("<leader>b", "<cmd>BufferLineCyclePrev<cr>")
|
|
nmap("<leader>n", "<cmd>BufferLineCycleNext<cr>")
|
|
nmap("<leader>gb", "<cmd>BufferLinePick<cr>")
|
|
nmap("<leader>w", "<cmd>bdelete!<cr>")
|
|
nmap("<leader>f", "<cmd>Telescope live_grep<cr>")
|
|
-- toggle terminal in both modes
|
|
nmap("<leader>t", "<cmd>FloatermToggle<cr>")
|
|
map("t", "<leader>t", "<cmd>FloatermToggle<cr>")
|
|
|
|
-- lsp on_attach mappings
|
|
local on_attach = function(client, bufnr)
|
|
if (not bufnr) then
|
|
return
|
|
end
|
|
-- Enable completion triggered by <c-x><c-o>
|
|
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
|
|
|
|
-- Mappings.
|
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
|
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)
|
|
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', '<cmd>lua vim.lsp.buf.format({ async = true })<CR>', bufopts)
|
|
|
|
require "coq".lsp_ensure_capabilities {}
|
|
require 'illuminate'.on_attach(client)
|
|
require 'lsp-format'.on_attach(client)
|
|
|
|
-- format on save does not work for python for some reason
|
|
--[[if client.supports_method("textDocument/formatting") then
|
|
vim.api.nvim_clear_autocmds({ group = augroup, buffer = bufnr })
|
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
|
group = augroup,
|
|
buffer = bufnr,
|
|
callback = function()
|
|
vim.lsp.buf.format({ bufnr = bufnr })
|
|
end
|
|
})
|
|
end ]]
|
|
--
|
|
end
|
|
|
|
-- lsp config setup
|
|
local lsp = require "lspconfig"
|
|
lsp.hls.setup { on_attach = on_attach } -- haskell language server
|
|
lsp.ccls.setup { on_attach = on_attach }
|
|
lsp.pyright.setup { on_attach = on_attach }
|
|
lsp.tsserver.setup { on_attach = on_attach }
|
|
lsp.marksman.setup { on_attach = on_attach }
|
|
lsp.rust_analyzer.setup { on_attach = on_attach }
|
|
lsp.lua_ls.setup { on_attach = on_attach,
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { 'vim' }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
vim.cmd("colorscheme carbonfox")
|
|
-- kill eslint_d on exit
|
|
local on_leave_group = vim.api.nvim_create_augroup("OnLeaveGroup", {})
|
|
vim.api.nvim_create_autocmd("VimLeave", {
|
|
group = on_leave_group,
|
|
command = "silent !killall -q eslint_d",
|
|
})
|
|
|
|
-- packer boilerplate
|
|
local fn = vim.fn
|
|
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
|
if fn.empty(fn.glob(install_path)) > 0 then
|
|
packer_bootstrap = fn.system({ 'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim',
|
|
install_path })
|
|
end
|
|
|
|
return require('packer').startup(function(use)
|
|
use 'wbthomason/packer.nvim'
|
|
use 'nvim-lua/plenary.nvim'
|
|
use { "lukas-reineke/lsp-format.nvim",
|
|
config = function()
|
|
require("lsp-format").setup {
|
|
python = {
|
|
sync = true,
|
|
force = true,
|
|
exclude = { "pyright" },
|
|
},
|
|
javascript = {
|
|
exclude = { "tsserver" }
|
|
}
|
|
}
|
|
end
|
|
}
|
|
use 'neovim/nvim-lspconfig'
|
|
use {
|
|
'ms-jpq/coq_nvim',
|
|
branch = 'coq',
|
|
event = "VimEnter",
|
|
config = 'vim.cmd[[COQnow]]'
|
|
}
|
|
use { 'ms-jpq/coq.artifacts', branch = 'artifacts' }
|
|
use { 'ms-jpq/coq.thirdparty', branch = '3p' }
|
|
use {
|
|
'nvim-treesitter/nvim-treesitter',
|
|
run = ':TSUpdate',
|
|
config = function()
|
|
require('nvim-treesitter.configs').setup {
|
|
highlight = {
|
|
enable = true
|
|
},
|
|
}
|
|
end
|
|
}
|
|
use { 'kyazdani42/nvim-tree.lua',
|
|
requires = {
|
|
'kyazdani42/nvim-web-devicons'
|
|
},
|
|
config = function() require('nvim-tree').setup {} end
|
|
}
|
|
--use { 'jose-elias-alvarez/typescript.nvim',
|
|
-- config = function() require("typescript")
|
|
use {
|
|
'jose-elias-alvarez/null-ls.nvim',
|
|
config = function()
|
|
local null_ls = require("null-ls")
|
|
local lsp_conf = require("lspconfig")
|
|
|
|
-- util.root_pattern returns a function
|
|
local find_pyproject = lsp_conf.util.root_pattern('pyproject.toml')
|
|
local find_flake8 = lsp_conf.util.root_pattern('.flake8')
|
|
|
|
local isort = null_ls.builtins.formatting.isort.with({
|
|
cwd = function(params)
|
|
return find_pyproject(params.root) or params.root
|
|
end
|
|
})
|
|
local black = null_ls.builtins.formatting.black.with({
|
|
extra_args = { "--config", "pyproject.toml" },
|
|
cwd = function(params)
|
|
return find_pyproject(params.root) or params.root
|
|
end
|
|
})
|
|
local flake8 = null_ls.builtins.diagnostics.flake8.with({
|
|
cwd = function(params)
|
|
return find_flake8(params.root) or params.root
|
|
end
|
|
})
|
|
local eslint_d_format = null_ls.builtins.formatting.eslint_d
|
|
local eslint_d_diag = null_ls.builtins.diagnostics.eslint_d
|
|
local eslint_d_code = null_ls.builtins.code_actions.eslint_d
|
|
local gitsigns = null_ls.builtins.code_actions.gitsigns
|
|
|
|
null_ls.setup {
|
|
debug = true,
|
|
on_attach = on_attach,
|
|
log_level = "debug"
|
|
}
|
|
null_ls.register({ isort, black, flake8, gitsigns })
|
|
null_ls.register({ name = "eslint_d", sources = { eslint_d_code, eslint_d_diag, eslint_d_format } })
|
|
end,
|
|
requires = { "nvim-lua/plenary.nvim" },
|
|
}
|
|
use {
|
|
'folke/trouble.nvim',
|
|
config = function()
|
|
require("trouble").setup {
|
|
nmap("<leader>xx", "<cmd>TroubleToggle<cr>"),
|
|
}
|
|
end
|
|
}
|
|
use {
|
|
'akinsho/bufferline.nvim',
|
|
tag = "v2.*",
|
|
requires = 'kyazdani42/nvim-web-devicons',
|
|
config = function()
|
|
require("bufferline").setup {
|
|
options = {
|
|
diagnostics = "nvim_lsp",
|
|
}
|
|
}
|
|
end
|
|
}
|
|
use { "EdenEast/nightfox.nvim",
|
|
config = function()
|
|
require("nightfox").setup {}
|
|
end
|
|
}
|
|
use {
|
|
"nvim-lualine/lualine.nvim",
|
|
event = "VimEnter",
|
|
config = function()
|
|
require("lualine").setup {
|
|
options = { theme = 'auto', globalstatus = true },
|
|
sections = { lualine_x = { 'filetype' } }
|
|
}
|
|
end,
|
|
requires = { 'kyazdani42/nvim-web-devicons', opt = true }
|
|
}
|
|
use {
|
|
"startup-nvim/startup.nvim",
|
|
requires = { "nvim-telescope/telescope.nvim", "nvim-lua/plenary.nvim" },
|
|
config = function()
|
|
require "startup".setup()
|
|
end
|
|
}
|
|
use 'RRethy/vim-illuminate'
|
|
use {
|
|
'nvim-telescope/telescope.nvim',
|
|
requires = { 'nvim-lua/plenary.nvim' },
|
|
config = function()
|
|
require("telescope").setup {}
|
|
end
|
|
}
|
|
use {
|
|
'j-hui/fidget.nvim',
|
|
config = function()
|
|
require('fidget').setup {}
|
|
end
|
|
}
|
|
use 'voldikss/vim-floaterm'
|
|
use {
|
|
'kkoomen/vim-doge',
|
|
run = ':call doge#install()'
|
|
}
|
|
use { 'norcalli/nvim-colorizer.lua',
|
|
config = function()
|
|
require('colorizer').setup {
|
|
'css',
|
|
'javascript',
|
|
}
|
|
end,
|
|
}
|
|
use { 'lewis6991/gitsigns.nvim',
|
|
config = function()
|
|
require('gitsigns').setup {
|
|
on_attach = function()
|
|
nmap('<leader>hd', '<cmd>Gitsigns diffthis<cr>')
|
|
nmap('<leader>hp', '<cmd>Gitsigns preview_hunk<cr>')
|
|
nmap('<leader>td', '<cmd>Gitsigns toggle_deleted<cr>')
|
|
end
|
|
}
|
|
end
|
|
}
|
|
use { 'sudormrfbin/cheatsheet.nvim',
|
|
-- default toggle is <leader>?
|
|
requires = {
|
|
{ 'nvim-telescope/telescope.nvim' },
|
|
{ 'nvim-lua/popup.nvim' },
|
|
{ 'nvim-lua/plenary.nvim' },
|
|
}
|
|
}
|
|
if packer_bootstrap then
|
|
require('packer').sync()
|
|
end
|
|
end)
|
|
|