3 Commits

13 changed files with 192 additions and 355 deletions

View File

@@ -1,5 +1,8 @@
require("set") require("set")
require("remap") require("remap")
require("lsp")
-- Set up lazy
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then

View File

@@ -0,0 +1,13 @@
return {
cmd = {
'clangd'
},
root_markers = {
'.clangd',
'compile_commands.json'
},
filetypes = {
'c',
'cpp'
}
}

View File

@@ -0,0 +1,20 @@
return {
cmd = {
'lua-language-server'
},
filetypes = {
'lua'
},
root_markers = {
'.luarc.json',
'.luarc.jsonc',
'.git'
},
settings = {
Lua = {
runtime = {
version = 'LuaJIT'
}
}
}
}

View File

@@ -0,0 +1,5 @@
return {
cmd = { "neocmakelsp", "--stdio" },
filetypes = { "cmake" },
root_markers = { ".git", "README.md" }
}

View File

@@ -0,0 +1,20 @@
return {
cmd = {
'pyright-langserver', '--stdio'
},
settings = {
python = {
analysis = {
typeCheckingMode = "basic", -- or "strict", "off"
autoSearchPaths = true,
useLibraryCodeForTypes = true,
},
},
},
root_markers = {
'pyproject.toml', 'setup.py', 'setup.cfg', 'requirements.txt', '.git'
},
filetypes = {
'python'
},
}

View File

@@ -0,0 +1,11 @@
return {
cmd = {
'ruff', 'server'
},
filetypes = {
'python'
},
root_markers = {
'setup.py', 'setup.cfg', 'requirements.txt', '.git', 'ruff.toml'
}
}

View File

@@ -0,0 +1,27 @@
return {
cmd = { 'texlab' },
filetypes = { 'tex' },
root_markers = { '.git', '.latexmkrc' },
settings = {
texlab = {
rootDirectory = nil,
build = {
executable = 'latexmk',
args = { '-pdf', '-interaction=nonstopmode', '-synctex=1', '%f' },
onSave = false,
forwardSearchAfter = false,
},
forwardSearch = {
executable = nil,
args = {},
},
chktex = {
onOpenAndSave = false,
onEdit = false,
},
diagnosticsDelay = 300,
latexFormatter = 'tex-fmt',
bibtexFormatter = 'tex-fmt',
},
},
}

View File

@@ -0,0 +1,74 @@
-- Set up LSP
local lsp_configs = {}
for _, f in pairs(vim.api.nvim_get_runtime_file('lsp/*.lua', true)) do
local server_name = vim.fn.fnamemodify(f, ':t:r')
table.insert(lsp_configs, server_name)
end
vim.lsp.enable(lsp_configs)
vim.o.completeopt = "menu,menuone,noinsert"
vim.api.nvim_set_keymap("i", "<C-Space>", "<C-x><C-o>", { noremap = true })
-- TODO: Put this somewhere sensible
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('my.lsp', {}),
callback = function(args)
local client = assert(vim.lsp.get_client_by_id(args.data.client_id))
-- Make Tab accept the selected completion
vim.keymap.set('i', '<Tab>', function()
if vim.fn.pumvisible() == 1 then
return '<C-y>'
else
return '<Tab>'
end
end, { expr = true })
-- Make Enter just insert a newline (don't accept completion)
vim.keymap.set('i', '<CR>', function()
if vim.fn.pumvisible() == 1 then
return '<C-e><CR>'
else
return '<CR>'
end
end, { expr = true })
-- Enable auto-completion. Note: Use CTRL-Y to select an item. |complete_CTRL-Y|
if client:supports_method('textDocument/completion') then
-- Trigger autocompletion on EVERY keypress. May be slow!
local chars = {}; for i = 32, 126 do table.insert(chars, string.char(i)) end
client.server_capabilities.completionProvider.triggerCharacters = chars
vim.lsp.completion.enable(true, client.id, args.buf, { autotrigger = true })
end
vim.keymap.set('n', '<M-L>',
function() vim.lsp.buf.format({ bufnr = args.buf, timeout_ms = 1000 }) end,
{ desc = "Format" })
vim.keymap.set('i', '<M-L>',
function() vim.lsp.buf.format({ bufnr = args.buf, timeout_ms = 1000 }) end,
{ desc = "Format" })
-- if client:supports_method('textDocument/implementation') then
-- -- Create a keymap for vim.lsp.buf.implementation ...
-- end
-- -- Auto-format ("lint") on save.
-- -- Usually not needed if server supports "textDocument/willSaveWaitUntil".
-- if not client:supports_method('textDocument/willSaveWaitUntil')
-- and client:supports_method('textDocument/formatting') then
-- vim.api.nvim_create_autocmd('BufWritePre', {
-- group = vim.api.nvim_create_augroup('my.lsp', { clear = false }),
-- buffer = args.buf,
-- callback = function()
-- vim.lsp.buf.format({ bufnr = args.buf, id = client.id, timeout_ms = 1000 })
-- end,
-- })
-- end
end,
})

View File

@@ -1,26 +0,0 @@
return {
"hat0uma/csvview.nvim",
---@module "csvview"
---@type CsvView.Options
opts = {
parser = { comments = { "#", "//" } },
keymaps = {
-- Text objects for selecting fields
textobject_field_inner = { "if", mode = { "o", "x" } },
textobject_field_outer = { "af", mode = { "o", "x" } },
-- Excel-like navigation:
-- Use <Tab> and <S-Tab> to move horizontally between fields.
-- Use <Enter> and <S-Enter> to move vertically between rows and place the cursor at the end of the field.
-- Note: In terminals, you may need to enable CSI-u mode to use <S-Tab> and <S-Enter>.
jump_next_field_end = { "<Tab>", mode = { "n", "v" } },
jump_prev_field_end = { "<S-Tab>", mode = { "n", "v" } },
jump_next_row = { "<Enter>", mode = { "n", "v" } },
jump_prev_row = { "<S-Enter>", mode = { "n", "v" } },
},
},
cmd = { "CsvViewEnable", "CsvViewDisable", "CsvViewToggle" },
init = function()
vim.keymap.set("n", "<leader>ce", ":CsvViewEnable display_mode=border header_lnum=1<CR>")
vim.keymap.set("n", "<leader>cd", ":CsvViewDisable<CR>")
end
}

View File

@@ -1,193 +0,0 @@
return {
{
{
'VonHeikemen/lsp-zero.nvim',
branch = 'v3.x',
lazy = true,
config = false,
init = function()
-- Disable automatic setup, we are doing it manually
vim.g.lsp_zero_extend_cmp = 0
vim.g.lsp_zero_extend_lspconfig = 0
end
},
{
'williamboman/mason.nvim',
lazy = false,
opts = {
registries = {
"github:antsouchlos/mason-registry",
"github:mason-org/mason-registry"
}
}
},
-- Autocompletion
{
'hrsh7th/nvim-cmp',
event = 'InsertEnter',
dependencies = {
'L3MON4D3/LuaSnip',
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-path',
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lsp-signature-help',
'saadparwaiz1/cmp_luasnip'
},
config = function()
local lsp_zero = require('lsp-zero')
lsp_zero.extend_cmp()
local cmp = require('cmp')
cmp.setup({
sources = {
-- LuaFormatter off
{ name = 'path' },
{ name = 'nvim_lsp' },
{ name = 'nvim_lua' },
{ name = 'luasnip', keyword_length = 2 },
{ name = 'buffer', keyword_length = 3 },
{ name = 'nvim_lsp_signature_help' }
-- LuaFormatter on
},
formatting = lsp_zero.cmp_format(),
mapping = cmp.mapping.preset.insert({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
['<Tab>'] = cmp.mapping.confirm({
select = true
}),
['<C-Space>'] = cmp.mapping.complete()
}),
snippet = {
expand = function(args) require('luasnip').lsp_expand(args.body) end
}
})
cmp.setup.filetype('gitcommit', {
-- LuaFormatter off
sources = cmp.config.sources(
{ { name = 'git' } },
{ { name = 'buffer' } }
)
-- LuaFormatter on
})
cmp.setup.cmdline({
'/',
'?'
}, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{
name = 'buffer'
}
}
})
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{
name = 'path'
}
}, {
{
name = 'cmdline'
}
})
})
end
},
-- LSP
{
'neovim/nvim-lspconfig',
cmd = {
'LspInfo',
'LspInstall',
'LspStart'
},
event = {
'BufReadPre',
'BufNewFile'
},
dependencies = {
'hrsh7th/cmp-nvim-lsp',
'williamboman/mason-lspconfig.nvim',
"folke/trouble.nvim"
},
config = function()
local lsp_zero = require('lsp-zero')
lsp_zero.extend_lspconfig()
lsp_zero.on_attach(function(client, bufnr)
vim.keymap.set("n", "<leader>ld", function() vim.lsp.buf.definition() end, {
desc = "Go to definition"
})
vim.keymap.set("n", "<leader>lh", function() vim.lsp.buf.hover() end, {
desc = "Hover"
})
vim.keymap.set("n", "<leader>lr", ":Trouble lsp_references<CR>", {
desc = "Show references"
})
vim.keymap.set("n", "<leader>ln", function() vim.lsp.buf.rename() end, {
desc = "Rename"
})
vim.keymap.set("n", "<leader>ls", function() vim.lsp.buf.signature_help() end, {
desc = "Signature help"
})
vim.keymap.set("n", "<leader>la", function() vim.lsp.buf.code_action() end, {
desc = "Code actions"
})
end)
require('mason-lspconfig').setup({
ensure_installed = {
'clangd',
'pyright',
'cmake',
'texlab'
},
handlers = {
lsp_zero.default_setup,
lua_ls = function()
local lua_opts = lsp_zero.nvim_lua_ls()
require('lspconfig').lua_ls.setup(lua_opts)
end
}
})
require('lspconfig')['clangd'].setup {
cmd = {
"clangd",
"--background-index",
"--clang-tidy",
"--completion-style=bundled",
"--cross-file-rename",
"--header-insertion=iwyu",
-- Required for embedded system compilers
"--query-driver=/**/*g++",
"--offset-encoding=utf-16"
-- "-j=8",
-- "--malloc-trim",
-- "--pch-storage=memory"
}
}
-- require('lspconfig').matlab_ls.setup({
-- settings = {
-- filetypes = {
-- "matlab"
-- },
-- matlab = {
-- installPath = "/opt/matlab/R2023a/"
-- }
-- },
-- single_file_support = true
-- })
end
}
}
}

View File

@@ -0,0 +1,10 @@
return {
'williamboman/mason.nvim',
lazy = false,
opts = {
registries = {
"github:antsouchlos/mason-registry",
"github:mason-org/mason-registry"
}
}
}

View File

@@ -1,127 +0,0 @@
return {
{
'sbdchd/neoformat',
event = {
"BufReadPost",
"BufNewFile"
},
init = function()
----------------
-- Formatters
----------------
vim.api.nvim_create_autocmd("FileType", {
pattern = "python",
callback = function()
-- vim.g.neoformat_python_autopep8 = {
-- exe = 'autopep8',
-- args = {'--max-line-length', '79', '--experimental'},
-- -- replace = 1
-- }
-- vim.g.neoformat_enabled_python = {
-- 'autopep8'
-- }
vim.g.neoformat_enabled_python = {
'ruff'
}
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"cpp",
"c"
},
callback = function()
vim.g.neoformat_enabled_cpp = {
'clangformat'
}
vim.g.neoformat_enabled_c = {
'clangformat'
}
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "lua",
callback = function()
vim.g.neoformat_enable_lua = {
'luaformatter'
}
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "cmake",
callback = function()
vim.g.neoformat_enabled_cmake = {
'cmake-format'
}
end
})
-- Commented out rust formatter
-- vim.api.nvim_create_autocmd("FileType", {
-- pattern = "rust",
-- callback = function()
-- vim.g.neoformat_enabled_rust = {'rustfmt'}
-- end
-- })
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
vim.g.neoformat_markdown_mdformat = {
exe = 'mdformat',
args = {
'--wrap=79',
'--number'
},
replace = 1
}
vim.g.neoformat_enabled_markdown = {
'mdformat'
}
end
})
vim.api.nvim_create_autocmd("FileType", {
pattern = "tex",
callback = function()
vim.g.neoformat_tex_texfmt = {
exe = "tex-fmt",
args = {
"--stdin",
"--tabsize",
"4"
},
stdin = 1
}
vim.g.neoformat_enabled_tex = {
"texfmt"
}
end
})
----------------
-- Other
----------------
-- vim.cmd([[
-- augroup Neoformat
-- autocmd!
-- autocmd BufWritePre * undojoin | Neoformat
-- augroup END
-- ]])
vim.api.nvim_set_keymap('n', '<M-L>', '<cmd>Neoformat<cr>', {
noremap = true,
silent = true
})
vim.api.nvim_set_keymap('i', '<M-L>', '<cmd>Neoformat<cr>', {
noremap = true,
silent = true
})
end
}
}

View File

@@ -18,7 +18,7 @@ bindsym Control+Mod1+l exec $lock
bindsym Print exec grim -g "$(slurp -d)" - | wl-copy bindsym Print exec grim -g "$(slurp -d)" - | wl-copy
bindsym $mod+p exec kitty -e /usr/bin/expect -c "spawn python; expect \\"*>>> \\"; send \\"import numpy as np\n\\"; send \\"import sympy as sp\n\\"; send \\"import torch\n\\"; interact" bindsym $mod+p exec kitty -e /usr/bin/expect -c "spawn python; expect \\"*>>> \\"; send \\"import numpy as np\n\\"; send \\"import sympy as sp\n\\"; interact"
bindsym $mod+Return exec $term bindsym $mod+Return exec $term
bindsym $mod+Shift+q kill bindsym $mod+Shift+q kill
bindsym $mod+d exec $menu bindsym $mod+d exec $menu