|
|
|
@ -22,6 +22,8 @@ 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" |
|
|
|
@ -46,16 +48,27 @@ function imap(shortcut, command) |
|
|
|
|
map('i', shortcut, command) |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
if vim.fn.exists("g:neovide") then |
|
|
|
|
vim.g.neovide_refresh_rate = 140 |
|
|
|
|
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>") |
|
|
|
@ -72,8 +85,10 @@ nmap("<leader>t", "<cmd>FloatermToggle<cr>") |
|
|
|
|
map("t", "<leader>t", "<cmd>FloatermToggle<cr>") |
|
|
|
|
|
|
|
|
|
-- lsp on_attach mappings |
|
|
|
|
local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) |
|
|
|
|
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') |
|
|
|
|
|
|
|
|
@ -94,13 +109,15 @@ local on_attach = function(client, bufnr) |
|
|
|
|
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) |
|
|
|
|
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 |
|
|
|
|
if client.supports_method("textDocument/formatting") then |
|
|
|
|
-- 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, |
|
|
|
@ -108,7 +125,8 @@ local on_attach = function(client, bufnr) |
|
|
|
|
vim.lsp.buf.format({ bufnr = bufnr }) |
|
|
|
|
end |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
end ]] |
|
|
|
|
-- |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
-- lsp config setup |
|
|
|
@ -117,8 +135,9 @@ 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.sumneko_lua.setup { on_attach = on_attach, |
|
|
|
|
lsp.lua_ls.setup { on_attach = on_attach, |
|
|
|
|
settings = { |
|
|
|
|
Lua = { |
|
|
|
|
diagnostics = { |
|
|
|
@ -129,6 +148,12 @@ lsp.sumneko_lua.setup { on_attach = on_attach, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
@ -141,6 +166,20 @@ 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', |
|
|
|
@ -153,7 +192,8 @@ return require('packer').startup(function(use) |
|
|
|
|
use { |
|
|
|
|
'nvim-treesitter/nvim-treesitter', |
|
|
|
|
run = ':TSUpdate', |
|
|
|
|
config = function() require('nvim-treesitter.configs').setup { |
|
|
|
|
config = function() |
|
|
|
|
require('nvim-treesitter.configs').setup { |
|
|
|
|
highlight = { |
|
|
|
|
enable = true |
|
|
|
|
}, |
|
|
|
@ -166,26 +206,54 @@ return require('packer').startup(function(use) |
|
|
|
|
}, |
|
|
|
|
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() require("null-ls").setup { |
|
|
|
|
sources = { |
|
|
|
|
require("null-ls").builtins.formatting.eslint_d, |
|
|
|
|
require("null-ls").builtins.diagnostics.eslint_d, |
|
|
|
|
require("null-ls").builtins.code_actions.eslint_d, |
|
|
|
|
require("null-ls").builtins.diagnostics.flake8, |
|
|
|
|
require("null-ls").builtins.formatting.black.with { extra_args = { "--fast" } }, |
|
|
|
|
require("null-ls").builtins.formatting.isort, |
|
|
|
|
require("null-ls").builtins.code_actions.gitsigns |
|
|
|
|
} |
|
|
|
|
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>"); |
|
|
|
|
config = function() |
|
|
|
|
require("trouble").setup { |
|
|
|
|
nmap("<leader>xx", "<cmd>TroubleToggle<cr>"), |
|
|
|
|
} |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
@ -193,7 +261,8 @@ return require('packer').startup(function(use) |
|
|
|
|
'akinsho/bufferline.nvim', |
|
|
|
|
tag = "v2.*", |
|
|
|
|
requires = 'kyazdani42/nvim-web-devicons', |
|
|
|
|
config = function() require("bufferline").setup { |
|
|
|
|
config = function() |
|
|
|
|
require("bufferline").setup { |
|
|
|
|
options = { |
|
|
|
|
diagnostics = "nvim_lsp", |
|
|
|
|
} |
|
|
|
@ -201,7 +270,8 @@ return require('packer').startup(function(use) |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
use { "EdenEast/nightfox.nvim", |
|
|
|
|
config = function() require("nightfox").setup {} |
|
|
|
|
config = function() |
|
|
|
|
require("nightfox").setup {} |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
use { |
|
|
|
@ -242,9 +312,10 @@ return require('packer').startup(function(use) |
|
|
|
|
run = ':call doge#install()' |
|
|
|
|
} |
|
|
|
|
use { 'norcalli/nvim-colorizer.lua', |
|
|
|
|
config = function() require('colorizer').setup { |
|
|
|
|
'css'; |
|
|
|
|
'javascript'; |
|
|
|
|
config = function() |
|
|
|
|
require('colorizer').setup { |
|
|
|
|
'css', |
|
|
|
|
'javascript', |
|
|
|
|
} |
|
|
|
|
end, |
|
|
|
|
} |
|
|
|
|