mirror of
https://github.com/Smaug123/nix-dotfiles
synced 2025-10-13 10:28:39 +00:00
Tidy up
This commit is contained in:
@@ -78,7 +78,7 @@ vim.api.nvim_create_autocmd("BufReadPost", {
|
|||||||
|
|
||||||
-- Trim trailing whitespace on save
|
-- Trim trailing whitespace on save
|
||||||
function CleanExtraSpaces()
|
function CleanExtraSpaces()
|
||||||
local save_cursor = vim.api.nvim.win_get_cursor(0)
|
local save_cursor = vim.api.nvim_win_get_cursor(0)
|
||||||
local old_query = vim.fn.getreg("/")
|
local old_query = vim.fn.getreg("/")
|
||||||
vim.cmd("%s/\\s\\+$//e")
|
vim.cmd("%s/\\s\\+$//e")
|
||||||
vim.api.nvim_win_set_cursor(0, save_cursor)
|
vim.api.nvim_win_set_cursor(0, save_cursor)
|
||||||
|
@@ -183,7 +183,7 @@ end
|
|||||||
-- if handle then
|
-- if handle then
|
||||||
-- local stdout = handle:read("*all")
|
-- local stdout = handle:read("*all")
|
||||||
-- handle:close()
|
-- handle:close()
|
||||||
--
|
--
|
||||||
-- local allResults = {}
|
-- local allResults = {}
|
||||||
-- for match in string.gmatch(stdout, "([^%z]+)") do
|
-- for match in string.gmatch(stdout, "([^%z]+)") do
|
||||||
-- table.insert(allResults, match)
|
-- table.insert(allResults, match)
|
||||||
@@ -199,7 +199,7 @@ end
|
|||||||
-- return a < b -- If both or neither end with 'proj', sort alphabetically
|
-- return a < b -- If both or neither end with 'proj', sort alphabetically
|
||||||
-- end
|
-- end
|
||||||
-- end)
|
-- end)
|
||||||
--
|
--
|
||||||
-- for _, line in ipairs(allResults) do
|
-- for _, line in ipairs(allResults) do
|
||||||
-- table.insert(results, line)
|
-- table.insert(results, line)
|
||||||
-- end
|
-- end
|
||||||
@@ -234,7 +234,7 @@ vim.api.nvim_create_user_command("BuildFSharpProject", function(opts)
|
|||||||
})
|
})
|
||||||
:find()
|
:find()
|
||||||
end
|
end
|
||||||
end, { nargs = "?", complete = 'file' })
|
end, { nargs = "?", complete = "file" })
|
||||||
|
|
||||||
local function SetupFSharpKeyBindings()
|
local function SetupFSharpKeyBindings()
|
||||||
local status, whichkey = pcall(require, "which-key")
|
local status, whichkey = pcall(require, "which-key")
|
||||||
|
@@ -56,12 +56,31 @@ require("lspconfig").nil_ls.setup(coq.lsp_ensure_capabilities({
|
|||||||
},
|
},
|
||||||
}))
|
}))
|
||||||
|
|
||||||
-- Global mappings.
|
function ToggleLocList()
|
||||||
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
|
local winid = vim.fn.getloclist(0, { winid = 0 }).winid
|
||||||
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float)
|
if winid == 0 then
|
||||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev)
|
vim.cmd.lopen()
|
||||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next)
|
else
|
||||||
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist)
|
vim.cmd.lclose()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local whichkey_status, whichkey = pcall(require, "which-key")
|
||||||
|
if whichkey_status then
|
||||||
|
whichkey.register({
|
||||||
|
l = {
|
||||||
|
p = { vim.diagnostic.goto_prev, "Go to previous entry in loclist" },
|
||||||
|
n = { vim.diagnostic.goto_next, "Go to next entry in loclist" },
|
||||||
|
l = { ToggleLocList, "Toggle loclist" },
|
||||||
|
f = { vim.diagnostic.open_float, "Open current loclist entry in floating window" },
|
||||||
|
},
|
||||||
|
}, { prefix = vim.api.nvim_get_var("maplocalleader") })
|
||||||
|
else
|
||||||
|
vim.keymap.set("n", "<localleader>lp", vim.diagnostic.goto_prev)
|
||||||
|
vim.keymap.set("n", "<localleader>ln", vim.diagnostic.goto_next)
|
||||||
|
vim.keymap.set("n", "<localleader>ll", ToggleLocList)
|
||||||
|
vim.keymap.set("n", "<localleader>lf", vim.diagnostic.open_float)
|
||||||
|
end
|
||||||
|
|
||||||
-- Use LspAttach autocommand to only map the following keys
|
-- Use LspAttach autocommand to only map the following keys
|
||||||
-- after the language server attaches to the current buffer
|
-- after the language server attaches to the current buffer
|
||||||
@@ -74,8 +93,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
-- Buffer local mappings.
|
-- Buffer local mappings.
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
local opts = { buffer = ev.buf }
|
local opts = { buffer = ev.buf }
|
||||||
local status, whichkey = pcall(require, "which-key")
|
if whichkey_status then
|
||||||
if status then
|
|
||||||
whichkey.register({
|
whichkey.register({
|
||||||
g = {
|
g = {
|
||||||
D = { vim.lsp.buf.declaration, "Go to declaration" },
|
D = { vim.lsp.buf.declaration, "Go to declaration" },
|
||||||
@@ -114,7 +132,7 @@ vim.api.nvim_create_autocmd("LspAttach", {
|
|||||||
a = { vim.lsp.buf.code_action, "Select a code action" },
|
a = { vim.lsp.buf.code_action, "Select a code action" },
|
||||||
},
|
},
|
||||||
r = {
|
r = {
|
||||||
n = { vim.lsp.buf.rename, "Rename buffer" },
|
n = { vim.lsp.buf.rename, "Rename variable" },
|
||||||
},
|
},
|
||||||
D = { vim.lsp.buf.type_definition, "Go to type definition" },
|
D = { vim.lsp.buf.type_definition, "Go to type definition" },
|
||||||
}, { prefix = "<space>" })
|
}, { prefix = "<space>" })
|
||||||
|
Reference in New Issue
Block a user