nvim config setup
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
local dap = require("dap")
|
||||
dap.adapters.gdb = {
|
||||
type = "executable",
|
||||
command = "gdb",
|
||||
args = { "--interpreter=dap", "--eval-command", "set print pretty on" }
|
||||
}
|
||||
|
||||
dap.configurations.c = {
|
||||
{
|
||||
name = "Launch",
|
||||
type = "gdb",
|
||||
request = "launch",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = "${workspaceFolder}",
|
||||
stopAtBeginningOfMainSubprogram = false,
|
||||
},
|
||||
{
|
||||
name = "Select and attach to process",
|
||||
type = "gdb",
|
||||
request = "attach",
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
pid = function()
|
||||
local name = vim.fn.input('Executable name (filter): ')
|
||||
return require("dap.utils").pick_process({ filter = name })
|
||||
end,
|
||||
cwd = '${workspaceFolder}'
|
||||
},
|
||||
{
|
||||
name = 'Attach to gdbserver :1234',
|
||||
type = 'gdb',
|
||||
request = 'attach',
|
||||
target = 'localhost:1234',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}'
|
||||
},
|
||||
}
|
||||
@@ -1,37 +1,10 @@
|
||||
local lsp = require('lsp-zero')
|
||||
local lsp_zero = require('lsp-zero')
|
||||
|
||||
lsp.preset('recommended')
|
||||
|
||||
lsp.ensure_installed({
|
||||
--'eslint',
|
||||
--'html',
|
||||
--'lua_ls',
|
||||
'rust_analyzer',
|
||||
'jdtls',
|
||||
--'clangd',
|
||||
'zls',
|
||||
--'pylsp',
|
||||
'ols',
|
||||
})
|
||||
|
||||
local cmp = require('cmp')
|
||||
local cmp_select = {behaviour = cmp.SelectBehavior.Select}
|
||||
local cmp_mappings = lsp.defaults.cmp_mappings({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
})
|
||||
|
||||
lsp.set_preferences({
|
||||
sign_icons = { }
|
||||
})
|
||||
|
||||
lsp.setup_nvim_cmp({
|
||||
mapping = cmp_mappings
|
||||
})
|
||||
|
||||
lsp.on_attach(function(client, bufnr)
|
||||
local lsp_attach = function(client, bufnr)
|
||||
-- see :help lsp-zero-keybindings
|
||||
-- to learn the available actions
|
||||
-- lsp_zero.default_keymaps({buffer = bufnr})
|
||||
--
|
||||
local opts = {buffer = bufnr, remap = false}
|
||||
|
||||
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
|
||||
@@ -45,23 +18,189 @@ lsp.on_attach(function(client, bufnr)
|
||||
vim.keymap.set("n", "<leader>vrr", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
end)
|
||||
end
|
||||
|
||||
require('lspconfig').lua_ls.setup({
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'vim', 'turtle' },
|
||||
},
|
||||
},
|
||||
lsp_zero.extend_lspconfig({
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(),
|
||||
lsp_attach = lsp_attach,
|
||||
float_border = 'rounded',
|
||||
sign_text = true,
|
||||
})
|
||||
|
||||
local lspconfig = require('lspconfig')
|
||||
|
||||
require('mason').setup({})
|
||||
require('mason-lspconfig').setup({
|
||||
ensure_installed = {
|
||||
'lua_ls',
|
||||
'jdtls',
|
||||
'clangd',
|
||||
'zls',
|
||||
},
|
||||
handlers = {
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup({})
|
||||
end,
|
||||
|
||||
-- noop is an empty function that doesn't do anything
|
||||
clangd = function()
|
||||
lspconfig.clangd.setup({
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--log=verbose',
|
||||
'--header-interpolation=false', -- clangd doesn't find the files, annoying and unnecessary noise as a result
|
||||
},
|
||||
init_options = {
|
||||
fallbackFlags = {
|
||||
'-std=c23',
|
||||
'-std=c++20'
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
jdtls = function()
|
||||
lspconfig.jdtls.setup({
|
||||
cmd = {
|
||||
"java",
|
||||
"-Declipse.application=org.eclipse.jdt.ls.core.id1",
|
||||
"-Dosgi.bundles.defaultStartLevel=4",
|
||||
"-Declipse.product=org.eclipse.jdt.ls.core.product",
|
||||
"-Dlog.protocol=true",
|
||||
"-Dlog.level=ALL",
|
||||
"-Xms1g",
|
||||
"--add-modules=ALL-SYSTEM",
|
||||
"--add-opens",
|
||||
"java.base/java.util=ALL-UNNAMED",
|
||||
"--add-opens",
|
||||
"java.base/java.lang=ALL-UNNAMED",
|
||||
--
|
||||
},
|
||||
single_file_support = true,
|
||||
settings = {
|
||||
java = {
|
||||
signatureHelp = {enabled = true},
|
||||
import = {enabled = true},
|
||||
rename = {enabled = true}
|
||||
}
|
||||
},
|
||||
flags = {
|
||||
debounce_text_changes = 150,
|
||||
},
|
||||
init_options = {
|
||||
bundles = {},
|
||||
},
|
||||
})
|
||||
end,
|
||||
zls = lsp_zero.noop,
|
||||
lua_ls = function()
|
||||
lspconfig.lua_ls.setup({
|
||||
on_init = function(client)
|
||||
if client.workspace_folders then
|
||||
local path = client.workspace_folders[1].name
|
||||
if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're using
|
||||
-- (most likely LuaJIT in the case of Neovim)
|
||||
|
||||
version = 'LuaJIT'
|
||||
},
|
||||
-- Make the server aware of Neovim runtime files
|
||||
workspace = {
|
||||
checkThirdParty = false,
|
||||
library = {
|
||||
vim.env.VIMRUNTIME
|
||||
}
|
||||
}
|
||||
})
|
||||
end,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
globals = { 'turtle' },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end,
|
||||
ols = function()
|
||||
lspconfig.ols.setup({
|
||||
single_file_support = true,
|
||||
on_attach = function (client, buffer)
|
||||
print('reached ols')
|
||||
end
|
||||
})
|
||||
end,
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
local cmp = require('cmp')
|
||||
local cmp_select = {behaviour = cmp.SelectBehavior.Select}
|
||||
cmp.setup({
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
},
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require('luasnip').lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
|
||||
['<C-n>'] = cmp.mapping.select_next_item(cmp_select),
|
||||
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
}),
|
||||
formatting = lsp_zero.cmp_format(),
|
||||
})
|
||||
|
||||
require('lspconfig').ols.setup({
|
||||
single_file_support = true,
|
||||
on_attach = function (client, buffer)
|
||||
print('reached ols')
|
||||
end
|
||||
})
|
||||
-- lsp_zero.set_preferences({
|
||||
-- sign_icons = { }
|
||||
-- })
|
||||
--
|
||||
-- lsp_zero.setup_nvim_cmp({
|
||||
-- mapping = cmp_mappings
|
||||
-- })
|
||||
|
||||
lsp.setup()
|
||||
|
||||
-- require('lspconfig').lua_ls.setup({
|
||||
-- on_init = function(client)
|
||||
-- if client.workspace_folders then
|
||||
-- local path = client.workspace_folders[1].name
|
||||
-- if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then
|
||||
-- return
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, {
|
||||
-- -- runtime = {
|
||||
-- -- Tell the language server which version of Lua you're using
|
||||
-- -- (most likely LuaJIT in the case of Neovim)
|
||||
-- -- version = 'LuaJIT'
|
||||
-- -- },
|
||||
-- -- Make the server aware of Neovim runtime files
|
||||
-- workspace = {
|
||||
-- checkThirdParty = false,
|
||||
-- library = {
|
||||
-- vim.env.VIMRUNTIME
|
||||
-- }
|
||||
-- }
|
||||
-- })
|
||||
-- end,
|
||||
-- settings = {
|
||||
-- Lua = {
|
||||
-- diagnostics = {
|
||||
-- globals = { 'turtle' },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- })
|
||||
|
||||
-- lsp_zero.setup()
|
||||
|
||||
@@ -2,15 +2,8 @@ return require('packer').startup(function(use)
|
||||
-- Packer can manage itself
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
--themes ---- commenting out ones I'm not actively using
|
||||
--use ({'EdenEast/nightfox.nvim' })
|
||||
--use 'rebelot/kanagawa.nvim' --not too bad a theme
|
||||
use({ 'rose-pine/neovim', as = 'rose-pine' }) --pretty nice themes
|
||||
--end themes
|
||||
use({ 'rose-pine/neovim', as = 'rose-pine' })
|
||||
|
||||
|
||||
--use 'Tetralux/odin.vim' --odin lang syntax highlighting
|
||||
--use 'rust-lang/rust.vim' // don't need this anymore
|
||||
use 'nvim-telescope/telescope.nvim'
|
||||
use('nvim-treesitter/nvim-treesitter', {run = ':TSUpdate'})
|
||||
use 'nvim-treesitter/playground'
|
||||
@@ -19,21 +12,17 @@ return require('packer').startup(function(use)
|
||||
use 'mbbill/undotree'
|
||||
use 'theprimeagen/harpoon'
|
||||
use 'nvim-lualine/lualine.nvim'
|
||||
use 'mfussenegger/nvim-dap' -- debugger integration
|
||||
use 'tpope/vim-fugitive' -- git integration
|
||||
--LSP CONFIG
|
||||
--
|
||||
use {
|
||||
'VonHeikemen/lsp-zero.nvim',
|
||||
branch = 'v2.x',
|
||||
branch = 'v4.x',
|
||||
requires = {
|
||||
-- LSP Support
|
||||
{'neovim/nvim-lspconfig'}, -- Required
|
||||
{ -- Optional
|
||||
'williamboman/mason.nvim',
|
||||
run = function()
|
||||
pcall(vim.cmd, 'MasonUpdate')
|
||||
end,
|
||||
},
|
||||
{'williamboman/mason.nvim'}, -- Optional
|
||||
{'williamboman/mason-lspconfig.nvim'}, -- Optional
|
||||
|
||||
-- Autocompletion
|
||||
@@ -50,7 +39,4 @@ return require('packer').startup(function(use)
|
||||
}
|
||||
}
|
||||
|
||||
use {"akinsho/toggleterm.nvim", tag = '*', config = function()
|
||||
require("toggleterm").setup()
|
||||
end}
|
||||
end)
|
||||
|
||||
@@ -22,11 +22,30 @@ vim.keymap.set("n", "<leader>Y", "\"+Y")
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", {silent = true})
|
||||
|
||||
-- put nvim to background
|
||||
vim.keymap.set("n", "<leader>z", "<C-z>")
|
||||
vim.keymap.set("n", "<leader>bg", "<C-z>")
|
||||
|
||||
|
||||
-- invoke build scripts
|
||||
-- `build.sh`
|
||||
vim.keymap.set("n", "<leader>bo", ":!./build.sh ") -- Interactive for adding flags/options
|
||||
vim.keymap.set("n", "<leader>bb", ":!./build.sh <CR>")
|
||||
vim.keymap.set("n", "<leader>br", ":!./build.sh run<CR>")
|
||||
vim.keymap.set("n", "<leader>bR", ":!./build.sh release<CR>")
|
||||
vim.keymap.set("n", "<leader>bRr", ":!./build.sh release run<CR>")
|
||||
|
||||
-- zig build
|
||||
vim.keymap.set("n", "<leader>zbo", ":!zig build -D") -- Interactive for adding flags/options
|
||||
vim.keymap.set("n", "<leader>zbb", ":!zig build <CR>")
|
||||
vim.keymap.set("n", "<leader>zbr", ":!zig build run<CR>")
|
||||
vim.keymap.set("n", "<leader>zbR", ":!zig build -Doptimize=ReleaseSafe <CR>")
|
||||
vim.keymap.set("n", "<leader>zbRr", ":!zig build -Doptimize=ReleaseSafe run<CR>")
|
||||
vim.keymap.set("n", "<leader>zbt", ":!zig build -Dtarget=") -- Interactive to add target/other flags
|
||||
vim.keymap.set("n", "<leader>zbtR", ":!zig build -Doptimize=ReleaseSafe -Dtarget=") -- Interactive to add target/other flags
|
||||
|
||||
|
||||
-- emacs-inspired binds
|
||||
-- all <C-w> can be done w spacebar-w
|
||||
vim.keymap.set("n", "<leader>w", "<C-w>")
|
||||
vim.keymap.set("n", "<leader>qq", ":x<CR>")
|
||||
nnoremap("<leader>.", ":find ~/")
|
||||
nnoremap("<leader>fc", ":find ~/.config/nvim/lua/liamm/remap.lua<CR>")
|
||||
nnoremap("<leader>fc", ":find ~/personal/nixos/modules/old_configs/nvim/lua/liamm/remap.lua<CR>")
|
||||
|
||||
@@ -18,7 +18,7 @@ vim.opt.colorcolumn = ""
|
||||
|
||||
vim.opt.smartindent = true
|
||||
|
||||
vim.opt.wrap = false
|
||||
vim.opt.wrap = true
|
||||
|
||||
vim.opt.swapfile = false
|
||||
vim.opt.backup = false
|
||||
|
||||
Reference in New Issue
Block a user