|
|
|
@ -59,7 +59,7 @@ 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>") |
|
|
|
@ -88,44 +88,28 @@ 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) |
|
|
|
|
-- won't need format on save if it always works |
|
|
|
|
-- vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts) |
|
|
|
|
|
|
|
|
|
require "coq".lsp_ensure_capabilities {} |
|
|
|
|
require 'illuminate'.on_attach(client) |
|
|
|
|
|
|
|
|
|
-- format on save |
|
|
|
|
if client.supports_method("textDocument/formatting") then |
|
|
|
|
|
|
|
|
|
-- get filetype |
|
|
|
|
local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype") |
|
|
|
|
-- get null-ls supported sources |
|
|
|
|
local available = require "null-ls.sources".get_available(filetype, require("null-ls").methods.FORMATTING) |
|
|
|
|
|
|
|
|
|
local enable = false |
|
|
|
|
if #available > 0 then |
|
|
|
|
enable = client.name == "null-ls" |
|
|
|
|
else |
|
|
|
|
enable = not (client.name == "null-ls") |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
client.resolved_capabilities.document_formatting = enable |
|
|
|
|
client.resolved_capabilities.document_range_formatting = enable |
|
|
|
|
|
|
|
|
|
if client.resolved_capabilities.document_formatting then |
|
|
|
|
vim.api.nvim_create_autocmd("BufWritePre", { |
|
|
|
|
group = augroup, |
|
|
|
|
buffer = bufnr, |
|
|
|
|
callback = function() |
|
|
|
|
vim.lsp.buf.formatting_sync() |
|
|
|
|
end |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
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.rust_analyzer.setup { on_attach = on_attach } |
|
|
|
@ -187,11 +171,29 @@ return require('packer').startup(function(use) |
|
|
|
|
use { |
|
|
|
|
'jose-elias-alvarez/null-ls.nvim', |
|
|
|
|
config = function() require('null-ls').setup({ |
|
|
|
|
on_attach = function(client, bufnr) |
|
|
|
|
if client.supports_method("textDocument/formatting") then |
|
|
|
|
-- overwrites format on save if null-ls is loaded |
|
|
|
|
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, filter = function(client) |
|
|
|
|
return client.name == "null-ls" |
|
|
|
|
end |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
}) |
|
|
|
|
end |
|
|
|
|
end, |
|
|
|
|
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.formatting.black |
|
|
|
|
require("null-ls").builtins.diagnostics.flake8, |
|
|
|
|
require("null-ls").builtins.formatting.black, |
|
|
|
|
require("null-ls").builtins.code_actions.gitsigns |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
end, |
|
|
|
@ -266,6 +268,14 @@ return require('packer').startup(function(use) |
|
|
|
|
require('gitsigns').setup() |
|
|
|
|
end |
|
|
|
|
} |
|
|
|
|
use { |
|
|
|
|
'sudormrfbin/cheatsheet.nvim', |
|
|
|
|
requires = { |
|
|
|
|
{ 'nvim-telescope/telescope.nvim' }, |
|
|
|
|
{ 'nvim-lua/popup.nvim' }, |
|
|
|
|
{ 'nvim-lua/plenary.nvim' }, |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if packer_bootstrap then |
|
|
|
|
require('packer').sync() |
|
|
|
|
end |
|
|
|
|