chore(nvim): a bunch of things

This commit is contained in:
Afonso Franco 2024-03-17 12:32:47 +00:00
parent 9d8f5b9f53
commit b375840efb
Signed by: afonso
SSH key fingerprint: SHA256:gkVPzsQQJzqi21ntQBV6pXTx4bYI53rFGI4XtvCpwd4
13 changed files with 513 additions and 377 deletions

View file

@ -1,75 +0,0 @@
--KEYBINDINGS
local map = vim.api.nvim_set_keymap
local opts = { noremap = true, silent = true }
-- Move to previous/next
map('n', '<A-h>', '<Cmd>BufferLineCyclePrev<CR>', opts)
map('n', '<A-l>', '<Cmd>BufferLineCycleNext<CR>', opts)
-- Re-order to previous/next
map('n', '<A-H>', '<Cmd>BufferLineMovePrev<CR>', opts)
map('n', '<A-L>', '<Cmd>BufferLineMoveNext<CR>', opts)
-- Goto buffer in position...
map('n', '<A-1>', '<Cmd>BufferLineGoToBuffer 1<CR>', opts)
map('n', '<A-2>', '<Cmd>BufferLineGoToBuffer 2<CR>', opts)
map('n', '<A-3>', '<Cmd>BufferLineGoToBuffer 3<CR>', opts)
map('n', '<A-4>', '<Cmd>BufferLineGoToBuffer 4<CR>', opts)
map('n', '<A-5>', '<Cmd>BufferLineGoToBuffer 5<CR>', opts)
map('n', '<A-6>', '<Cmd>BufferLineGoToBuffer 6<CR>', opts)
map('n', '<A-7>', '<Cmd>BufferLineGoToBuffer 7<CR>', opts)
map('n', '<A-8>', '<Cmd>BufferLineGoToBuffer 8<CR>', opts)
map('n', '<A-9>', '<Cmd>BufferLineGoToBuffer 9<CR>', opts)
-- Close buffer
map('n', '<A-c>', '<Cmd>BufferLinePickClose<CR>', opts)
-- Set bufferline's options
require("bufferline").setup({
options = {
mode = "buffers",
numbers = "none",
close_command = "bdelete! %d",
right_mouse_command = "bdelete! %d",
left_mouse_command = "buffer %d",
middle_mouse_command = "bdelete! %d",
indicator = {
icon = "",
style = "icon",
},
buffer_close_icon = '',
modified_icon = '',
close_icon = '',
left_trunc_marker = '',
right_trunc_marker = '',
max_name_length = 18,
max_prefix_length = 15,
truncate_names = true,
tab_size = 18,
diagnostics = "nvim_lsp",
diagnostics_update_in_insert = true,
diagnostics_indicator = function(count, level, diagnostics_dict, context)
return "(" .. count .. ")"
end,
color_icons = true,
show_buffer_icons = true,
show_buffer_close_icons = true,
show_buffer_default_icon = true,
show_close_icon = true,
show_tab_indicators = true,
show_duplicate_prefix = true,
persist_buffer_sort = true,
separator_style = "slant",
enforce_regular_tabs = true,
always_show_bufferline = true,
hover = {
enabled = true,
delay = 200,
reveal = { 'close' }
},
sort_by = 'insert_after_current',
custom_filter = function(buf_number, buf_numbers)
-- filter out filetypes you don't want to see
if vim.bo[buf_number].filetype ~= "" then
return true
end
end,
}
})

View file

@ -10,10 +10,23 @@ end
require("luasnip/loaders/from_vscode").lazy_load()
local check_backspace = function()
local col = vim.fn.col "." - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match "%s"
local col = vim.fn.col(".") - 1
return col == 0 or vim.fn.getline("."):sub(col, col):match("%s")
end
local lspkind_status_ok, lspkind = pcall(require, "lspkind")
if not lspkind_status_ok then
return
end
cmp.event:on("menu_opened", function()
vim.b.copilot_suggestion_hidden = true
end)
cmp.event:on("menu_closed", function()
vim.b.copilot_suggestion_hidden = false
end)
-- 󰃐 󰆩 󰙅 󰛡  󰅲 some other good icons
local kind_icons = {
Text = "󰉿",
@ -46,26 +59,27 @@ local kind_icons = {
}
-- find more here: https://www.nerdfonts.com/cheat-sheet
cmp.setup {
cmp.setup({
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body) -- For `luasnip` users.
end,
},
mapping = {
["<C-b>"] = cmp.mapping(cmp.mapping.scroll_docs(-1), { "i", "c" }),
["<C-f>"] = cmp.mapping(cmp.mapping.scroll_docs(1), { "i", "c" }),
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-u>"] = cmp.mapping.scroll_docs(-4),
["<C-d>"] = cmp.mapping.scroll_docs(4),
["<C-e>"] = cmp.mapping.abort(),
["<C-y>"] = cmp.mapping(
cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
{ "i", "c" }
),
["<C-Space>"] = cmp.mapping(cmp.mapping.complete(), { "i", "c" }),
["<C-y>"] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
["<C-e>"] = cmp.mapping {
i = cmp.mapping.abort(),
c = cmp.mapping.close(),
},
-- Accept currently selected item. If none selected, do nothing.
["<CR>"] = cmp.mapping.confirm {
behavior = cmp.ConfirmBehavior.Replace,
select = false
},
["<C-k>"] = cmp.mapping(function(fallback)
if luasnip.expandable() then
luasnip.expand()
@ -83,47 +97,29 @@ cmp.setup {
else
fallback()
end
end
),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
else
fallback()
end
end, {
"i",
"s",
}),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
else
fallback()
end
end, {
"i",
"s",
}),
end),
},
formatting = {
fields = { "kind", "abbr", "menu" },
format = function(entry, vim_item)
-- Kind icons
-- if vim.tbl_contains({ "nvim_lsp" }, entry.source.name) then
-- tailwind = require("tailwindcss-colorizer-cmp")
-- return tailwind.formatter(entry, vim_item)
-- else
vim_item.kind = string.format('[%s %s]', kind_icons[vim_item.kind], vim_item.kind) -- This concatonates the icons with the name of the item kind
vim_item.menu = ({
nvim_lsp = "[LSP]",
["vim-dadbod-completion"] = "[󰆼]",
nvim_lua = "[LSP]",
path = "[Path]",
})[entry.source.name]
return vim_item
-- end
end,
format = lspkind.cmp_format({
mode = "symbol_text", -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters (e.g 50 will not show more than 50 characters)
-- can also be a function to dynamically calculate max width such as
-- maxwidth = function() return math.floor(0.45 * vim.o.columns) end,
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead (must define maxwidth first)
show_labelDetails = true, -- show labelDetails in menu. Disabled by default
-- The function below will be called before any actual modifications from lspkind
-- so that you can provide more controls on popup customization. (See [#30](https://github.com/onsails/lspkind-nvim/pull/30))
before = function(entry, vim_item)
vim_item.menu = ({
nvim_lsp = "[LSP]",
nvim_lua = "[LSP]",
path = "[Path]",
})[entry.source.name]
return vim_item
end,
}),
},
sorting = {
comparators = {
@ -133,8 +129,8 @@ cmp.setup {
--Make entries that start with underline appear after
function(entry1, entry2)
local _, entry1_under = entry1.completion_item.label:find "^_+"
local _, entry2_under = entry2.completion_item.label:find "^_+"
local _, entry1_under = entry1.completion_item.label:find("^_+")
local _, entry2_under = entry2.completion_item.label:find("^_+")
entry1_under = entry1_under or 0
entry2_under = entry2_under or 0
if entry1_under > entry2_under then
@ -143,51 +139,17 @@ cmp.setup {
return true
end
end,
}
},
sources = cmp.config.sources(
{
{
name = "nvim_lsp",
entry_filter = function(entry, context)
local kind = entry:get_kind()
vim.api.nvim_out_write(kind .. '\n')
if kind == "Text" then return false end
return true
end
},
{ name = 'orgmode' },
{ name = 'nvim_lua' },
{ name = 'luasnip' },
--{ name = "vim-dadbod-completion" },
{ name = "path" },
},
{
--This sources will only show up if there aren't any sources from the other list
{ name = "buffer", keyword_length = 5 },
}
),
confirm_opts = {
behavior = cmp.ConfirmBehavior.Replace,
select = false,
},
window = {
documentation = cmp.config.window.bordered(),
completion = cmp.config.window.bordered({
winhighlight = "Normal:Pmenu,FloatBorder:Pmenu,CursorLine:PmenuSel,Search:None"
})
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "nvim_lua" },
{ name = "luasnip" },
{ name = "path" },
}, {
{ name = "buffer", keyword_length = 5 },
}),
})
},
experimental = {
ghost_text = false,
native_menu = false,
},
}
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
cmp.event:on(
'confirm_done',
cmp_autopairs.on_confirm_done()
)
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())

View file

@ -0,0 +1,10 @@
require("conform").setup({
formatters_by_ft = {
python = { "black" },
javascript = { "prettierd" },
markdown = { "mdformat" },
},
format_on_save = {
lsp_fallback = true,
},
})

View file

@ -1,28 +1,29 @@
require('copilot').setup({
suggestion = {
enabled = true,
auto_trigger = true,
debounce = 75,
keymap = {
accept = "<C-h>",
accept_word = false,
accept_line = false,
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
suggestion = {
enabled = true,
auto_trigger = false,
debounce = 75,
keymap = {
accept = "<C-h>",
accept_word = false,
accept_line = false,
--Option key + ] or [
next = "<M-]>",
prev = "<M-[>",
dismiss = "<C-]>",
},
},
},
filetypes = {
yaml = false,
markdown = true,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = 'node', -- Node.js version must be > 16.x
server_opts_overrides = {},
filetypes = {
yaml = false,
markdown = true,
help = false,
gitcommit = false,
gitrebase = false,
hgcommit = false,
svn = false,
cvs = false,
["."] = false,
},
copilot_node_command = 'node', -- Node.js version must be > 16.x
server_opts_overrides = {},
})

View file

@ -1,17 +1,22 @@
local dap = require("dap")
dap.adapters.lldb = {
type = 'server',
port = "${port}",
executable = {
command = '/Users/afonso/.local/share/nvim/mason/bin/codelldb',
args = {"--port", "${port}"},
}
type = 'server',
port = "${port}",
executable = {
command = '/Users/afonso/.local/share/nvim/mason/bin/codelldb',
args = { "--port", "${port}" },
}
}
dap.adapters.codelldb = {
type = 'server',
host = '127.0.0.1',
port = 13000
}
dap.configurations.c = {
{
name = "codelldb: With args",
name = "Manually start codelldb",
type = "codelldb",
request = "launch",
program = function()
@ -24,6 +29,19 @@ dap.configurations.c = {
cwd = '${workspaceFolder}',
stopOnEntry = false,
},
{
name = "Auto start codelldb",
type = "lldb",
request = "launch",
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
args = function()
local args = vim.fn.input('Arguments: ')
return args ~= '' and { args } or nil
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
},
}

View file

@ -1,49 +1,49 @@
local lazy = require('lazy')
local lazy = require("lazy")
lazy.setup({
'lewis6991/impatient.nvim',
"lewis6991/impatient.nvim",
-------------------------------------------THEMES------------------------------------------
{
'catppuccin/nvim',
"catppuccin/nvim",
name = "catppuccin",
lazy = false,
priority = 1000,
opts = {}
opts = {},
},
'sainnhe/gruvbox-material',
"sainnhe/gruvbox-material",
-------------------------------------------------------MFP---------------------------------
{
'susliko/tla.nvim',
opts = {}
"susliko/tla.nvim",
opts = {},
},
-------------------------------------------------------QOL---------------------------------
{
'jbyuki/instant.nvim',
"jbyuki/instant.nvim",
config = function()
vim.g.instant_username = 'afonso'
end
vim.g.instant_username = "afonso"
end,
},
'vimpostor/vim-tpipeline',
"vimpostor/vim-tpipeline",
{
'TobinPalmer/pastify.nvim',
cmd = { 'Pastify' },
opts = {}
"TobinPalmer/pastify.nvim",
cmd = { "Pastify" },
opts = {},
},
--Python notebooks
{
'luk400/vim-jukit',
"luk400/vim-jukit",
config = function()
require 'plugins.jukit'
require("plugins.jukit")
end,
ft = { 'python', 'json' }
ft = { "python", "json" },
},
{
@ -51,49 +51,49 @@ lazy.setup({
cmd = "Copilot",
event = "InsertEnter",
config = function()
require 'plugins.copilot'
require("plugins.copilot")
end,
},
--Nvim to browser
'subnut/nvim-ghost.nvim',
"subnut/nvim-ghost.nvim",
{
'declancm/cinnamon.nvim',
"declancm/cinnamon.nvim",
opts = {
scroll_limit = 10000,
always_scroll = true,
}
},
},
{
"folke/todo-comments.nvim",
event = "VeryLazy",
dependencies = { "nvim-lua/plenary.nvim" },
opts = {}
opts = {},
},
{
'folke/zen-mode.nvim',
"folke/zen-mode.nvim",
event = "VeryLazy",
opts = {
vim.keymap.set('n', '<leader>z', '<Cmd> ZenMode <CR>', { noremap = true, silent = true })
}
vim.keymap.set("n", "<leader>z", "<Cmd> ZenMode <CR>", { noremap = true, silent = true }),
},
},
--Change add and remove surroundings from words
'tpope/vim-surround',
"tpope/vim-surround",
{
'NvChad/nvim-colorizer.lua',
opts = {}
"NvChad/nvim-colorizer.lua",
opts = {},
},
'mbbill/undotree',
"mbbill/undotree",
--Tmux navigation
{
'alexghergh/nvim-tmux-navigation',
"alexghergh/nvim-tmux-navigation",
opts = {
disable_when_zoomed = true, -- defaults to false
keybindings = {
@ -101,56 +101,57 @@ lazy.setup({
down = "<F6>",
up = "<F7>",
right = "<F8>",
}
}
},
},
},
-- Rename variable pop up
'stevearc/dressing.nvim',
"stevearc/dressing.nvim",
{
'windwp/nvim-autopairs',
"windwp/nvim-autopairs",
config = function()
require 'plugins.autopairs'
end
require("plugins.autopairs")
end,
},
'nvim-tree/nvim-web-devicons',
"nvim-tree/nvim-web-devicons",
{
'nvim-lualine/lualine.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons', opt = true },
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons", opt = true },
config = function()
require 'plugins.lualine'
end
require("plugins.lualine")
end,
},
{
'stevearc/oil.nvim',
opts = {}
"stevearc/oil.nvim",
opts = {},
},
-------------------------------------------------------LSP----------------------------------------------
{
'hrsh7th/nvim-cmp',
"hrsh7th/nvim-cmp",
dependencies = {
'hrsh7th/cmp-nvim-lsp', -- lsp
'hrsh7th/cmp-nvim-lua', -- Nvim API completions
'hrsh7th/cmp-nvim-lsp-signature-help', -- Show function signatures
'hrsh7th/cmp-buffer', --buffer completions
'hrsh7th/cmp-path', --path completions
'hrsh7th/cmp-cmdline', --cmdline completions
'L3MON4D3/LuaSnip',
'rafamadriz/friendly-snippets',
'saadparwaiz1/cmp_luasnip',
"hrsh7th/cmp-nvim-lsp", -- lsp
"hrsh7th/cmp-nvim-lua", -- Nvim API completions
"hrsh7th/cmp-nvim-lsp-signature-help", -- Show function signatures
"hrsh7th/cmp-buffer", --buffer completions
"hrsh7th/cmp-path", --path completions
"hrsh7th/cmp-cmdline", --cmdline completions
"L3MON4D3/LuaSnip",
"rafamadriz/friendly-snippets",
"saadparwaiz1/cmp_luasnip",
"onsails/lspkind.nvim", --lspkind icons
},
config = function()
require 'plugins.cmp'
end
require("plugins.cmp")
end,
},
--LSP Status
'j-hui/fidget.nvim',
"j-hui/fidget.nvim",
{
"rcarriga/nvim-dap-ui",
@ -169,7 +170,7 @@ lazy.setup({
dap.listeners.before.event_exited["dapui_config"] = function()
dapui.close()
end
end
end,
},
{
"jay-babu/mason-nvim-dap.nvim",
@ -179,84 +180,89 @@ lazy.setup({
"mfussenegger/nvim-dap",
},
opts = {
handlers = {}
handlers = {},
},
},
{
"mfussenegger/nvim-dap",
config = function()
require 'plugins.dap'
end
require("plugins.dap")
end,
},
{
'williamboman/mason.nvim',
"williamboman/mason.nvim",
config = function()
require 'plugins.mason'
end
require("plugins.mason")
end,
},
'williamboman/mason-lspconfig.nvim',
"williamboman/mason-lspconfig.nvim",
{
'neovim/nvim-lspconfig',
"neovim/nvim-lspconfig",
config = function()
require 'plugins.lspconfig'
end
require("plugins.lspconfig")
end,
},
{
'nvimtools/none-ls.nvim',
event = "VeryLazy",
"stevearc/conform.nvim",
config = function()
require 'plugins.none-ls'
end
require("plugins.conform")
end,
},
{
'lervag/vimtex',
"lervag/vimtex",
config = function()
require 'plugins.vimtex'
end
require("plugins.vimtex")
end,
},
{
'mrcjkb/rustaceanvim',
version = '^4', -- Recommended
ft = { 'rust' },
"mrcjkb/rustaceanvim",
version = "^4", -- Recommended
ft = { "rust" },
},
"barreiroleo/ltex-extra.nvim",
-------------------------------------------------------------------------------------------
-- Syntax Highlighting
{
'nvim-treesitter/nvim-treesitter',
"nvim-treesitter/nvim-treesitter",
config = function()
require 'plugins.treesitter'
end
require("plugins.treesitter")
end,
},
'kaarmu/typst.vim',
"kaarmu/typst.vim",
--Sticky headers
{
'nvim-treesitter/nvim-treesitter-context',
"nvim-treesitter/nvim-treesitter-context",
config = function()
require 'plugins.treesitter-context'
end
require("plugins.treesitter-context")
end,
},
"runoshun/vim-alloy",
--does so much
{
'nvim-telescope/telescope.nvim',
tag = '0.1.4',
"nvim-telescope/telescope.nvim",
tag = "0.1.4",
-- or , branch = '0.1.x',
dependencies = { 'nvim-lua/plenary.nvim' },
config = function() require('plugins.telescope') end
dependencies = { "nvim-lua/plenary.nvim" },
config = function()
require("plugins.telescope")
end,
},
--Discord Rich Presence
'andweeb/presence.nvim'
"andweeb/presence.nvim",
--Vim be good
'ThePrimeagen/vim-be-good',
})

View file

@ -1,75 +1,91 @@
local mason_lspconfig = require "mason-lspconfig"
local lspconfig = require "lspconfig"
local mason_lspconfig = require("mason-lspconfig")
local lspconfig = require("lspconfig")
mason_lspconfig.setup({
automatic_installation = false
automatic_installation = false,
})
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
local telescope = require("telescope.builtin")
local conform = require("conform")
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local bufopts = { noremap = true, silent = true, buffer = ev.buf }
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, bufopts)
vim.keymap.set("n", "<space>q", vim.diagnostic.setloclist, bufopts)
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts)
vim.keymap.set("n", "gd", telescope.lsp_definitions, bufopts)
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts)
vim.keymap.set("n", "gi", telescope.lsp_implementations, bufopts)
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts)
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, 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", "gr", telescope.lsp_references, bufopts)
vim.keymap.set("n", "<space>ge", function() vim.diagnostic.goto_next() end, bufopts)
vim.keymap.set("n", "<space>gE", function() vim.diagnostic.goto_prev() end, bufopts)
vim.keymap.set("n", "<space>fo", function() conform.format({ lsp_fallback = true }) end, bufopts)
end,
})
-- ADD NVIM CMP AS A CAPABILITY
local lsp_defaults = lspconfig.util.default_config
local capabilities =
vim.tbl_deep_extend("force", lsp_defaults.capabilities, require("cmp_nvim_lsp").default_capabilities())
mason_lspconfig.setup_handlers({
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["lua_ls"] = function()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
settings = {
Lua = {
library = {
unpack(vim.api.nvim_get_runtime_file('', true))
},
diagnostics = {
globals = { 'vim' },
},
},
},
})
end,
["hls"] = function()
lspconfig["hls"].setup({
capabilities = capabilities,
filetypes = { 'haskell', 'lhaskell', 'cabal' },
})
end,
["ltex"] = function()
lspconfig["ltex"].setup({
capabilities = capabilities,
--Local on attach
on_attach = function(_, _)
-- rest of your on_attach process.
require("ltex_extra").setup()
end,
})
end
})
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { noremap = true, silent = true }
local bufopts = { noremap = true, silent = true, buffer = bufnr }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, 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', 'gr', vim.lsp.buf.references, bufopts)
vim.keymap.set('n', '<space>ge', function() vim.diagnostic.goto_next() end, bufopts)
vim.keymap.set('n', '<space>gE', function() vim.diagnostic.goto_prev() end, bufopts)
vim.keymap.set('n', '<space>fo', function() vim.lsp.buf.format { async = true } end, bufopts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, bufopts)
end
-- ADD NVIM CMP AS A CAPABILITY
local lsp_defaults = lspconfig.util.default_config
local capabilities = vim.tbl_deep_extend(
'force',
lsp_defaults.capabilities,
require('cmp_nvim_lsp').default_capabilities()
)
mason_lspconfig.setup_handlers {
-- This is a default handler that will be called for each installed server (also for new servers that are installed during a session)
function(server_name)
lspconfig[server_name].setup {
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
}
end,
}
lspconfig["ocamllsp"].setup {
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities,
}
vim.g.rustaceanvim = {
server = {
on_attach = on_attach,
flags = lsp_flags,
capabilities = capabilities
capabilities = capabilities,
},
}

View file

@ -1,8 +0,0 @@
local M = {}
M.change_theme = function(scheme)
vim.cmd('colorscheme ' .. scheme)
end
return M

View file

@ -1,6 +0,0 @@
local present, silicon = pcall(require,'silicon')
-- Generate image of lines in a visual selection
vim.keymap.set('v', '<Leader>s', function() silicon.visualise_api() end )
-- Generate image of a whole buffer, with lines in a visual selection highlighted
vim.keymap.set('v', '<Leader>bs', function() silicon.visualise_api({to_clip = true, show_buf = true}) end )