fixed formatting in vim
This commit is contained in:
@@ -0,0 +1,23 @@
|
|||||||
|
## LSP
|
||||||
|
Get type definition | <space>D
|
||||||
|
Rename symbol | <space>rn
|
||||||
|
Code action | <space>ca
|
||||||
|
Find references | gr
|
||||||
|
Format file | <space>f
|
||||||
|
Goto declaration | gD
|
||||||
|
Goto definition | gd
|
||||||
|
Toggle hover over symbol | K
|
||||||
|
Goto implementation | gi
|
||||||
|
Get signature | <C-k>
|
||||||
|
Add folder to workspace | <space>wa
|
||||||
|
Remove folder from workspace | <space>wr
|
||||||
|
List workspace folders | <space>wl
|
||||||
|
|
||||||
|
## Diagnostics
|
||||||
|
Open diagnostics as floating window | <space>e
|
||||||
|
Goto next diagnostic | [d
|
||||||
|
Goto previous diagnostic | ]d
|
||||||
|
Show diagnostics | <space>q
|
||||||
|
|
||||||
|
## Misc
|
||||||
|
Find in project | <leader>f
|
||||||
+38
-28
@@ -59,7 +59,7 @@ nmap("<leader>b", "<cmd>BufferLineCyclePrev<cr>")
|
|||||||
nmap("<leader>n", "<cmd>BufferLineCycleNext<cr>")
|
nmap("<leader>n", "<cmd>BufferLineCycleNext<cr>")
|
||||||
nmap("<leader>gb", "<cmd>BufferLinePick<cr>")
|
nmap("<leader>gb", "<cmd>BufferLinePick<cr>")
|
||||||
nmap("<leader>w", "<cmd>bdelete!<cr>")
|
nmap("<leader>w", "<cmd>bdelete!<cr>")
|
||||||
|
nmap("<leader>f", "<cmd>Telescope live_grep<cr>")
|
||||||
-- toggle terminal in both modes
|
-- toggle terminal in both modes
|
||||||
nmap("<leader>t", "<cmd>FloatermToggle<cr>")
|
nmap("<leader>t", "<cmd>FloatermToggle<cr>")
|
||||||
map("t", "<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>rn', vim.lsp.buf.rename, bufopts)
|
||||||
vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, 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', '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 "coq".lsp_ensure_capabilities {}
|
||||||
require 'illuminate'.on_attach(client)
|
require 'illuminate'.on_attach(client)
|
||||||
|
|
||||||
-- format on save
|
-- format on save
|
||||||
if client.supports_method("textDocument/formatting") then
|
if client.supports_method("textDocument/formatting") then
|
||||||
|
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||||
-- get filetype
|
group = augroup,
|
||||||
local filetype = vim.api.nvim_buf_get_option(bufnr, "filetype")
|
buffer = bufnr,
|
||||||
-- get null-ls supported sources
|
callback = function()
|
||||||
local available = require "null-ls.sources".get_available(filetype, require("null-ls").methods.FORMATTING)
|
vim.lsp.buf.format({ bufnr = bufnr })
|
||||||
|
end
|
||||||
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
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- lsp config setup
|
-- lsp config setup
|
||||||
local lsp = require "lspconfig"
|
local lsp = require "lspconfig"
|
||||||
lsp.hls.setup { on_attach = on_attach } -- haskell language server
|
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.pyright.setup { on_attach = on_attach }
|
||||||
lsp.tsserver.setup { on_attach = on_attach }
|
lsp.tsserver.setup { on_attach = on_attach }
|
||||||
lsp.rust_analyzer.setup { on_attach = on_attach }
|
lsp.rust_analyzer.setup { on_attach = on_attach }
|
||||||
@@ -187,11 +171,29 @@ return require('packer').startup(function(use)
|
|||||||
use {
|
use {
|
||||||
'jose-elias-alvarez/null-ls.nvim',
|
'jose-elias-alvarez/null-ls.nvim',
|
||||||
config = function() require('null-ls').setup({
|
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 = {
|
sources = {
|
||||||
require('null-ls').builtins.formatting.eslint_d,
|
require('null-ls').builtins.formatting.eslint_d,
|
||||||
require('null-ls').builtins.diagnostics.eslint_d,
|
require('null-ls').builtins.diagnostics.eslint_d,
|
||||||
require("null-ls").builtins.code_actions.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,
|
end,
|
||||||
@@ -266,6 +268,14 @@ return require('packer').startup(function(use)
|
|||||||
require('gitsigns').setup()
|
require('gitsigns').setup()
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
use {
|
||||||
|
'sudormrfbin/cheatsheet.nvim',
|
||||||
|
requires = {
|
||||||
|
{ 'nvim-telescope/telescope.nvim' },
|
||||||
|
{ 'nvim-lua/popup.nvim' },
|
||||||
|
{ 'nvim-lua/plenary.nvim' },
|
||||||
|
}
|
||||||
|
}
|
||||||
if packer_bootstrap then
|
if packer_bootstrap then
|
||||||
require('packer').sync()
|
require('packer').sync()
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ alias ucpserver='/home/frosty/Programs/Rust/UnifiedCopyPaste/target/debug/server
|
|||||||
alias fixWifi='sudo rmmod iwlmvm; sudo rmmod iwlwifi; sudo modprobe iwlmvm; sudo modprobe iwlwifi'
|
alias fixWifi='sudo rmmod iwlmvm; sudo rmmod iwlwifi; sudo modprobe iwlmvm; sudo modprobe iwlwifi'
|
||||||
alias weather='curl wttr.in'
|
alias weather='curl wttr.in'
|
||||||
alias sshLANL='ssh -t -l rhnatyshyn wtrw.lanl.gov ssh ch-fe.lanl.gov'
|
alias sshLANL='ssh -t -l rhnatyshyn wtrw.lanl.gov ssh ch-fe.lanl.gov'
|
||||||
|
alias vim='nvim'
|
||||||
function tunnelLANL() {
|
function tunnelLANL() {
|
||||||
if [ -n "$1" ]
|
if [ -n "$1" ]
|
||||||
then
|
then
|
||||||
|
|||||||
Reference in New Issue
Block a user