Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nvim lua master #656

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 94 additions & 12 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ P.S. You can delete this when you're done too. It's your config now! :)
-- NOTE: Must happen before plugins are loaded (otherwise wrong leader will be used)
vim.g.mapleader = ' '
vim.g.maplocalleader = ' '

require 'custom.remap'
-- [[ Setting options ]]
-- See `:help vim.opt`
-- NOTE: You can change these options as you wish!
Expand Down Expand Up @@ -367,7 +367,11 @@ require('lazy').setup {
local builtin = require 'telescope.builtin'
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<leader>pf', builtin.find_files, { desc = '[S]earch [F]iles' })
vim.keymap.set('n', '<C-p>', builtin.git_files, { desc = 'git files search' })
vim.keymap.set('n', '<leader>ps', function()
builtin.grep_string { search = vim.fn.input 'Grep > ' }
end, { desc = '[P]roject [S]earch}' })
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
Expand Down Expand Up @@ -534,10 +538,86 @@ require('lazy').setup {
-- - settings (table): Override the default settings passed when initializing the server.
-- For example, to see the options for `lua_ls`, you could go to: https://luals.github.io/wiki/settings/
local servers = {
-- clangd = {},
-- gopls = {},
-- pyright = {},
-- rust_analyzer = {},
typos_lsp = {},
clangd = {
keys = {
{ '<leader>cR', '<cmd>ClangdSwitchSourceHeader<cr>', desc = 'Switch Source/Header (C/C++)' },
},
root_dir = function(fname)
return require('lspconfig.util').root_pattern(
'Makefile',
'configure.ac',
'configure.in',
'config.h.in',
'meson.build',
'meson_options.txt',
'build.ninja'
)(fname) or require('lspconfig.util').root_pattern('compile_commands.json', 'compile_flags.txt')(fname) or require('lspconfig.util').find_git_ancestor(
fname
)
end,
capabilities = {
offsetEncoding = { 'utf-16' },
},
cmd = {
'clangd',
'--background-index',
'--clang-tidy',
'--header-insertion=iwyu',
'--completion-style=detailed',
'--function-arg-placeholders',
'--fallback-style=llvm',
},
init_options = {
usePlaceholders = true,
completeUnimported = true,
clangdFileStatus = true,
},
},
gopls = {
keys = {
-- Workaround for the lack of a DAP strategy in neotest-go: https://github.com/nvim-neotest/neotest-go/issues/12
{ '<leader>td', "<cmd>lua require('dap-go').debug_test()<CR>", desc = 'Debug Nearest (Go)' },
},
settings = {
gopls = {
gofumpt = true,
codelenses = {
gc_details = false,
generate = true,
regenerate_cgo = true,
run_govulncheck = true,
test = true,
tidy = true,
upgrade_dependency = true,
vendor = true,
},
hints = {
assignVariableTypes = true,
compositeLiteralFields = true,
compositeLiteralTypes = true,
constantValues = true,
functionTypeParameters = true,
parameterNames = true,
rangeVariableTypes = true,
},
analyses = {
fieldalignment = true,
nilness = true,
unusedparams = true,
unusedwrite = true,
useany = true,
},
usePlaceholders = true,
completeUnimported = true,
staticcheck = true,
directoryFilters = { '-.git', '-.vscode', '-.idea', '-.vscode-test', '-node_modules' },
semanticTokens = true,
},
},
},
-- pylyzer = {},
rust_analyzer = {},
-- ... etc. See `:help lspconfig-all` for a list of all the pre-configured LSPs
--
-- Some languages (like typescript) have entire language plugins that can be useful:
Expand Down Expand Up @@ -720,6 +800,7 @@ require('lazy').setup {
end,
},

{ 'catppuccin/nvim', name = 'catppuccin', priority = 1000 },
{ -- You can easily change to a different colorscheme.
-- Change the name of the colorscheme plugin below, and then
-- change the command in the config to whatever the name of that colorscheme is
Expand All @@ -730,7 +811,7 @@ require('lazy').setup {
priority = 1000, -- make sure to load this before all the other start plugins
config = function()
-- Load the colorscheme here
vim.cmd.colorscheme 'tokyonight-night'
vim.cmd.colorscheme 'catppuccin-mocha'

-- You can configure highlights by doing something like
vim.cmd.hi 'Comment gui=none'
Expand Down Expand Up @@ -776,7 +857,7 @@ require('lazy').setup {

---@diagnostic disable-next-line: missing-fields
require('nvim-treesitter.configs').setup {
ensure_installed = { 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc' },
ensure_installed = { 'go', 'git_rebase', 'cpp', 'bash', 'c', 'html', 'lua', 'markdown', 'vim', 'vimdoc', 'scala' },
-- Autoinstall languages that are not installed
auto_install = true,
highlight = { enable = true },
Expand All @@ -793,24 +874,25 @@ require('lazy').setup {
},

-- The following two comments only work if you have downloaded the kickstart repo, not just copy pasted the
-- init.lua. If you want these files, they are in the repository, so you can just download them and
-- put them in the right spots if you want.

-- NOTE: Next step on your Neovim journey: Add/Configure additional plugins for kickstart
--
-- Here are some example plugins that I've included in the kickstart repository.
-- Uncomment any of the lines below to enable them (you will need to restart nvim).
--
-- require 'kickstart.plugins.debug',
-- require 'kickstart.plugins.indent_line',
require 'kickstart.plugins.debug',
require 'kickstart.plugins.indent_line',

-- NOTE: The import below can automatically add your own plugins, configuration, etc from `lua/custom/plugins/*.lua`
-- This is the easiest way to modularize your config.
--
-- Uncomment the following line and add your plugins to `lua/custom/plugins/*.lua` to get going.
-- For additional information see: :help lazy.nvim-lazy.nvim-structuring-your-plugins
-- { import = 'custom.plugins' },
{ import = 'custom.plugins' },
}
-- { import = 'custom.plugins' },


-- The line beneath this is called `modeline`. See `:help modeline`
-- vim: ts=2 sts=2 sw=2 et
11 changes: 11 additions & 0 deletions lua/custom/plugins/autopairs.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
return {
'windwp/nvim-autopairs',
dependencies = { 'hrsh7th/nvim-cmp' },
config = function()
require('nvim-autopairs').setup {}
-- If you want to automatically add `(` after selecting a function or method
local cmp_autopairs = require 'nvim-autopairs.completion.cmp'
local cmp = require 'cmp'
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
end,
}
51 changes: 51 additions & 0 deletions lua/custom/plugins/dap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
return {
'mfussenegger/nvim-dap',
optional = true,
dependencies = {
-- Ensure C/C++ debugger is installed
'williamboman/mason.nvim',
optional = true,
opts = function(_, opts)
if type(opts.ensure_installed) == 'table' then
vim.list_extend(opts.ensure_installed, { 'codelldb' })
end
end,
},
opts = function()
local dap = require 'dap'
if not dap.adapters['codelldb'] then
require('dap').adapters['codelldb'] = {
type = 'server',
host = 'localhost',
port = '${port}',
executable = {
command = 'codelldb',
args = {
'--port',
'${port}',
},
},
}
end
for _, lang in ipairs { 'c', 'cpp' } do
dap.configurations[lang] = {
{
type = 'codelldb',
request = 'launch',
name = 'Launch file',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
end,
cwd = '${workspaceFolder}',
},
{
type = 'codelldb',
request = 'attach',
name = 'Attach to process',
processId = require('dap.utils').pick_process,
cwd = '${workspaceFolder}',
},
}
end
end,
}
23 changes: 23 additions & 0 deletions lua/custom/plugins/harpoon.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
return {
'theprimeagen/harpoon',
--dependencies = 'nvim-lua/plenary.nvim',
config = function()
local mark = require 'harpoon.mark'
local ui = require 'harpoon.ui'

vim.keymap.set('n', '<leader>a', mark.add_file, { desc = 'Add current file to harpoon' })
vim.keymap.set('n', '<C-e>', ui.toggle_quick_menu, { desc = ' harpoon menu' })
vim.keymap.set('n', '<C-h>', function()
ui.nav_file(1)
end)
vim.keymap.set('n', '<C-t>', function()
ui.nav_file(2)
end)
vim.keymap.set('n', '<C-n>', function()
ui.nav_file(3)
end)
vim.keymap.set('n', '<C-s>', function()
ui.nav_file(4)
end)
end,
}
25 changes: 25 additions & 0 deletions lua/custom/plugins/lsp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
return {
"scalameta/nvim-metals",
dependencies = {
"nvim-lua/plenary.nvim",
},
ft = { "scala", "sbt", "java" },
opts = function()
local metals_config = require("metals").bare_config()
metals_config.on_attach = function(client, bufnr)
-- your on_attach function
end

return metals_config
end,
config = function(self, metals_config)
local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true })
vim.api.nvim_create_autocmd("FileType", {
pattern = self.ft,
callback = function()
require("metals").initialize_or_attach(metals_config)
end,
group = nvim_metals_group,
})
end
}
6 changes: 6 additions & 0 deletions lua/custom/plugins/undotree.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
return {
'mbbill/undotree',
config = function()
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)
end,
}
7 changes: 7 additions & 0 deletions lua/custom/plugins/vim-fugitive.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
return {
'tpope/vim-fugitive',

config = function()
vim.keymap.set('n', '<leader>gs', vim.cmd.Git, { desc = '[G]it [S]tatus' })
end,
}
1 change: 1 addition & 0 deletions lua/custom/remap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex, { desc = '[P]roject [V]iew' })
Loading