updated some depreciated LSP stuff
This commit is contained in:
parent
bd5af3b7d4
commit
2b717818af
|
@ -1,8 +1,8 @@
|
||||||
--set some aliases to make typing this faster.
|
--set some aliases to make typing this faster.
|
||||||
local cmd=vim.cmd
|
local cmd = vim.cmd
|
||||||
local opt=vim.opt
|
local opt = vim.opt
|
||||||
local fn=vim.fn
|
local fn = vim.fn
|
||||||
local map=vim.api.nvim_set_keymap
|
local map = vim.api.nvim_set_keymap
|
||||||
|
|
||||||
--leader key is set through a variable, for some reason.
|
--leader key is set through a variable, for some reason.
|
||||||
vim.g.mapleader = ';'
|
vim.g.mapleader = ';'
|
||||||
|
@ -13,63 +13,63 @@ require('impatient')
|
||||||
require('packages')
|
require('packages')
|
||||||
|
|
||||||
--helper functions
|
--helper functions
|
||||||
local function keyCode(string)
|
local function keyCode(string)
|
||||||
return vim.api.nvim_replace_termcodes(str, true, true, true, true)
|
return vim.api.nvim_replace_termcodes(str, true, true, true, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
--options using vim.opt (aliased, of course.)
|
--options using vim.opt (aliased, of course.)
|
||||||
opt.mouse='a'
|
opt.mouse = 'a'
|
||||||
opt.lazyredraw=true
|
opt.lazyredraw = true
|
||||||
opt.termguicolors=true
|
opt.termguicolors = true
|
||||||
opt.autoread=true
|
opt.autoread = true
|
||||||
opt.swapfile=false
|
opt.swapfile = false
|
||||||
opt.history=500
|
opt.history = 500
|
||||||
opt.formatoptions='rojq'
|
opt.formatoptions = 'rojq'
|
||||||
--disable hard text wrapping, will only wrap visually.
|
--disable hard text wrapping, will only wrap visually.
|
||||||
opt.textwidth=0
|
opt.textwidth = 0
|
||||||
opt.wrapmargin=0
|
opt.wrapmargin = 0
|
||||||
opt.wrap=true
|
opt.wrap = true
|
||||||
opt.linebreak=true
|
opt.linebreak = true
|
||||||
opt.breakindent=true
|
opt.breakindent = true
|
||||||
--add ruler to side of screen.
|
--add ruler to side of screen.
|
||||||
opt.number=true
|
opt.number = true
|
||||||
--displays cordinates of your cursor in statusbar
|
--displays cordinates of your cursor in statusbar
|
||||||
opt.ruler=true
|
opt.ruler = true
|
||||||
--always leave 5 cells between cursor and side of window.
|
--always leave 5 cells between cursor and side of window.
|
||||||
opt.scrolloff=5
|
opt.scrolloff = 5
|
||||||
opt.sidescrolloff=5
|
opt.sidescrolloff = 5
|
||||||
--better command line completion
|
--better command line completion
|
||||||
opt.wildmenu=true
|
opt.wildmenu = true
|
||||||
--ignore case in search if search is all lowercase.
|
--ignore case in search if search is all lowercase.
|
||||||
opt.ignorecase=true
|
opt.ignorecase = true
|
||||||
opt.smartcase=true
|
opt.smartcase = true
|
||||||
--show unfinished commands in statusbar.
|
--show unfinished commands in statusbar.
|
||||||
opt.showcmd=true
|
opt.showcmd = true
|
||||||
--regex stuff
|
--regex stuff
|
||||||
opt.magic=true
|
opt.magic = true
|
||||||
--always have a status line
|
--always have a status line
|
||||||
opt.laststatus=2
|
opt.laststatus = 2
|
||||||
--tab stuff
|
--tab stuff
|
||||||
opt.tabstop=4
|
opt.tabstop = 4
|
||||||
opt.shiftwidth=0 --zero inherrits tabstop.
|
opt.shiftwidth = 0 --zero inherrits tabstop.
|
||||||
opt.autoindent=true
|
opt.autoindent = true
|
||||||
opt.smartindent=true
|
opt.smartindent = true
|
||||||
opt.smarttab=true
|
opt.smarttab = true
|
||||||
--space based tabs.
|
--space based tabs.
|
||||||
-- opt.softtabstop=-1 --negative value inherrits shiftwidth.
|
-- opt.softtabstop=-1 --negative value inherrits shiftwidth.
|
||||||
-- opt.expandtab=true
|
-- opt.expandtab=true
|
||||||
--highlight search results as you type.
|
--highlight search results as you type.
|
||||||
opt.hlsearch=true
|
opt.hlsearch = true
|
||||||
opt.incsearch=true
|
opt.incsearch = true
|
||||||
--foling stuff
|
--foling stuff
|
||||||
opt.foldlevelstart=5
|
opt.foldlevelstart = 5
|
||||||
cmd([[source ~/.config/nvim/foldtext.vimrc]])
|
cmd([[source ~/.config/nvim/foldtext.vimrc]])
|
||||||
opt.foldmethod='indent'
|
opt.foldmethod = 'indent'
|
||||||
opt.foldtext='minimal_foldtext()'
|
opt.foldtext = 'minimal_foldtext()'
|
||||||
opt.fillchars='stl:=,stlnc: ,vert:|,fold:-'
|
opt.fillchars = 'stl:=,stlnc: ,vert:|,fold:-'
|
||||||
opt.foldcolumn='4'
|
opt.foldcolumn = '4'
|
||||||
opt.foldenable=true
|
opt.foldenable = true
|
||||||
opt.foldignore=''
|
opt.foldignore = ''
|
||||||
|
|
||||||
--sets colorscheme. to get a list of avalible options, do colorscheme <Space> <C-d>
|
--sets colorscheme. to get a list of avalible options, do colorscheme <Space> <C-d>
|
||||||
vim.cmd 'colorscheme moonfly'
|
vim.cmd 'colorscheme moonfly'
|
||||||
|
@ -77,71 +77,71 @@ vim.cmd 'colorscheme moonfly'
|
||||||
--function for venn.nvim
|
--function for venn.nvim
|
||||||
-- venn.nvim: enable or disable keymappings
|
-- venn.nvim: enable or disable keymappings
|
||||||
function _G.Toggle_venn()
|
function _G.Toggle_venn()
|
||||||
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
local venn_enabled = vim.inspect(vim.b.venn_enabled)
|
||||||
if venn_enabled == "nil" then
|
if venn_enabled == "nil" then
|
||||||
vim.b.venn_enabled = true
|
vim.b.venn_enabled = true
|
||||||
vim.cmd[[setlocal ve=all]]
|
vim.cmd [[setlocal ve=all]]
|
||||||
-- draw a line on HJKL keystokes
|
-- draw a line on HJKL keystokes
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "J", "<C-v>j:VBox<CR>", { noremap = true })
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "K", "<C-v>k:VBox<CR>", { noremap = true })
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "L", "<C-v>l:VBox<CR>", { noremap = true })
|
||||||
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "n", "H", "<C-v>h:VBox<CR>", { noremap = true })
|
||||||
-- draw a box by pressing "f" with visual selection
|
-- draw a box by pressing "f" with visual selection
|
||||||
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", {noremap = true})
|
vim.api.nvim_buf_set_keymap(0, "v", "f", ":VBox<CR>", { noremap = true })
|
||||||
else
|
else
|
||||||
vim.cmd[[setlocal ve=]]
|
vim.cmd [[setlocal ve=]]
|
||||||
vim.cmd[[mapclear <buffer>]]
|
vim.cmd [[mapclear <buffer>]]
|
||||||
vim.b.venn_enabled = nil
|
vim.b.venn_enabled = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--keyboard mappings
|
--keyboard mappings
|
||||||
local opts = { noremap=true, silent=true }
|
local opts = { noremap = true, silent = true }
|
||||||
--toggle spell check
|
--toggle spell check
|
||||||
map('n', '<leader>sp', ':setlocal spell!<CR>', opts)
|
map('n', '<leader>sp', ':setlocal spell!<CR>', opts)
|
||||||
--[[ --easily create splits
|
--[[ --easily create splits
|
||||||
map('n', '<leader>|', ':vs<CR>', opts) ]]
|
map('n', '<leader>|', ':vs<CR>', opts) ]]
|
||||||
--[[ map('n', '<leader>-', ':sp<CR>', opts)
|
--[[ map('n', '<leader>-', ':sp<CR>', opts)
|
||||||
--use ctrl+direction to move between splits. ]]
|
--use ctrl+direction to move between splits. ]]
|
||||||
map('n', '<C-h>', '<C-w>h', opts)
|
map('n', '<C-h>', '<C-w>h', opts)
|
||||||
map('n', '<C-j>', '<C-w>j', opts)
|
map('n', '<C-j>', '<C-w>j', opts)
|
||||||
map('n', '<C-k>', '<C-w>k', opts)
|
map('n', '<C-k>', '<C-w>k', opts)
|
||||||
map('n', '<C-l>', '<C-w>l', opts)
|
map('n', '<C-l>', '<C-w>l', opts)
|
||||||
--toggle folds with space.
|
--toggle folds with space.
|
||||||
map('', '<Space>', 'za', opts)
|
map('', '<Space>', 'za', opts)
|
||||||
--clear highlighting with leader+h
|
--clear highlighting with leader+h
|
||||||
map('', '<leader>h', ':nohls<CR>', opts)
|
map('', '<leader>h', ':nohls<CR>', opts)
|
||||||
--open nvim-tree with leader+t
|
--open nvim-tree with leader+t
|
||||||
map('n', '<leader>t', ':NvimTreeToggle<CR>', opts)
|
map('n', '<leader>t', ':NvimTreeToggle<CR>', opts)
|
||||||
--open symbols-outline with leader+o
|
--open symbols-outline with leader+o
|
||||||
map('n', '<leader>o', ':SymbolsOutline<CR>', opts)
|
map('n', '<leader>o', ':SymbolsOutline<CR>', opts)
|
||||||
--telescope stuff
|
--telescope stuff
|
||||||
map('n', '<leader>ff', ':lua require "telescope".extensions.file_browser.file_browser()<CR>', opts)
|
map('n', '<leader>ff', ':lua require "telescope".extensions.file_browser.file_browser()<CR>', opts)
|
||||||
map('n', '<leader>fg', ':Telescope live_grep<CR>', opts)
|
map('n', '<leader>fg', ':Telescope live_grep<CR>', opts)
|
||||||
map('n', '<leader>fb', ':Telescope buffers<CR>', opts)
|
map('n', '<leader>fb', ':Telescope buffers<CR>', opts)
|
||||||
map('n', '<leader>fm', ':Telescope marks<CR>', opts)
|
map('n', '<leader>fm', ':Telescope marks<CR>', opts)
|
||||||
map('n', '<leader>fp', ':Telescope registers<CR>', opts)
|
map('n', '<leader>fp', ':Telescope registers<CR>', opts)
|
||||||
map('n', '<leader>fs', ':Telescope spell_suggest<CR>', opts)
|
map('n', '<leader>fs', ':Telescope spell_suggest<CR>', opts)
|
||||||
map('n', '<leader>fh', ':Telescope keymaps<CR>', opts)
|
map('n', '<leader>fh', ':Telescope keymaps<CR>', opts)
|
||||||
map('n', '<leader>fz', ':Telescope current_buffer_fuzzy_find<CR>', opts)
|
map('n', '<leader>fz', ':Telescope current_buffer_fuzzy_find<CR>', opts)
|
||||||
map('n', '<leader>fgc', ':Telescope git_commits<CR>', opts)
|
map('n', '<leader>fgc', ':Telescope git_commits<CR>', opts)
|
||||||
map('n', '<leader>fgb', ':Telescope git_branches<CR>', opts)
|
map('n', '<leader>fgb', ':Telescope git_branches<CR>', opts)
|
||||||
map('n', '<leader>fgs', ':Telescope git_stash<CR>', opts)
|
map('n', '<leader>fgs', ':Telescope git_stash<CR>', opts)
|
||||||
map('n', '<leader>ft', ':Telescope treesitter<CR>', opts)
|
map('n', '<leader>ft', ':Telescope treesitter<CR>', opts)
|
||||||
--Treesitter context
|
--Treesitter context
|
||||||
map('n', '<leader>c', ':TSContextToggle<CR>', opts)
|
map('n', '<leader>c', ':TSContextToggle<CR>', opts)
|
||||||
--tabline stuff (gt and gT are prev/next tab in stock vim)
|
--tabline stuff (gt and gT are prev/next tab in stock vim)
|
||||||
map('n', 'gf', ':TablineBufferNext<CR>', opts)
|
map('n', 'gf', ':TablineBufferNext<CR>', opts)
|
||||||
map('n', 'gF', ':TablineBufferPrevious<CR>', opts)
|
map('n', 'gF', ':TablineBufferPrevious<CR>', opts)
|
||||||
--gitsigns
|
--gitsigns
|
||||||
map('n', '<leader>bl', ':Gitsigns toggle_current_line_blame<CR>', opts)
|
map('n', '<leader>bl', ':Gitsigns toggle_current_line_blame<CR>', opts)
|
||||||
--trouble plugin.
|
--trouble plugin.
|
||||||
vim.keymap.set("n", "<leader>xx", "<cmd>TroubleToggle<cr>", opts)
|
vim.keymap.set("n", "<leader>xx", "<cmd>TroubleToggle<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>", opts)
|
vim.keymap.set("n", "<leader>xw", "<cmd>TroubleToggle workspace_diagnostics<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>", opts)
|
vim.keymap.set("n", "<leader>xd", "<cmd>TroubleToggle document_diagnostics<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>", opts)
|
vim.keymap.set("n", "<leader>xl", "<cmd>TroubleToggle loclist<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>", opts)
|
vim.keymap.set("n", "<leader>xq", "<cmd>TroubleToggle quickfix<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>lR", "<cmd>TroubleToggle lsp_references<cr>", opts)
|
vim.keymap.set("n", "<leader>lR", "<cmd>TroubleToggle lsp_references<cr>", opts)
|
||||||
vim.keymap.set("n", "<leader>lD", "<cmd>TroubleToggle lsp_definitions<cr>", opts)
|
vim.keymap.set("n", "<leader>lD", "<cmd>TroubleToggle lsp_definitions<cr>", opts)
|
||||||
-- toggle keymappings for venn using <leader>v
|
-- toggle keymappings for venn using <leader>v
|
||||||
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true})
|
vim.api.nvim_set_keymap('n', '<leader>v', ":lua Toggle_venn()<CR>", { noremap = true })
|
||||||
|
|
|
@ -2,17 +2,18 @@ local opts = {}
|
||||||
|
|
||||||
local on_attach = function()
|
local on_attach = function()
|
||||||
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
local function set_keymap(...) vim.api.nvim_set_keymap(...) end
|
||||||
|
|
||||||
local function set_option(...) vim.api.nvim_set_option(...) end
|
local function set_option(...) vim.api.nvim_set_option(...) end
|
||||||
|
|
||||||
-- Enable completion triggered by <c-x><c-o>
|
-- Enable completion triggered by <c-x><c-o>
|
||||||
set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
|
||||||
|
|
||||||
-- Mappings.
|
-- Mappings.
|
||||||
local opts = { noremap=true, silent=true }
|
local opts = { noremap = true, silent = true }
|
||||||
|
|
||||||
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
-- See `:help vim.lsp.*` for documentation on any of the below functions
|
||||||
set_keymap('', '<leader>lc', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
set_keymap('', '<leader>lc', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
|
||||||
set_keymap('', '<leader>lf', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
set_keymap('', '<leader>ld', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
|
||||||
set_keymap('', '<leader>lh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
set_keymap('', '<leader>lh', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
|
||||||
set_keymap('', '<leader>li', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
set_keymap('', '<leader>li', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
|
||||||
set_keymap('', '<leader>ls', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
set_keymap('', '<leader>ls', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
|
||||||
|
@ -26,18 +27,18 @@ local on_attach = function()
|
||||||
set_keymap('', '<leader>lo', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
set_keymap('', '<leader>lo', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
|
||||||
set_keymap('', '<leader>ln', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
set_keymap('', '<leader>ln', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
|
||||||
set_keymap('', '<leader>lp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
set_keymap('', '<leader>lp', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
|
||||||
set_keymap('', '<leader>lm', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
|
set_keymap('', '<leader>lm', '<cmd>lua vim.lsp.buf.format {async=true}<CR>', opts)
|
||||||
end
|
end
|
||||||
require("mason-lspconfig").setup_handlers({
|
require("mason-lspconfig").setup_handlers({
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require("lspconfig")[server_name].setup{}
|
require("lspconfig")[server_name].setup {}
|
||||||
on_attach()
|
on_attach()
|
||||||
end,
|
end,
|
||||||
["rust_analyzer"] = function()
|
["rust_analyzer"] = function()
|
||||||
require('rust-tools-setup')
|
require('rust-tools-setup')
|
||||||
on_attach()
|
on_attach()
|
||||||
end,
|
end,
|
||||||
["sumneko_lua"] = function ()
|
["sumneko_lua"] = function()
|
||||||
require('lspconfig').sumneko_lua.setup {
|
require('lspconfig').sumneko_lua.setup {
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
|
|
Loading…
Reference in a new issue